Giter Site home page Giter Site logo

Comments (4)

marxus avatar marxus commented on September 24, 2024 1

nice, this is actually very elegant way to express it.

from atlas.

marxus avatar marxus commented on September 24, 2024

btw i'm not sure about HCL interpolation internals. but from working on terraform this is an option on how to avoid this matter

table "some_table_1" { /* name for reference */
  name = "some_table" /* actual table_name */
  schema = schema.some_schema_1
  column "key" { type = varchar(255) }
  column "value" { type = longtext }
  primary_key {
    columns = [table.some_table_1.column.key]
  }
  index "key" {
    unique  = true
    columns = [table.some_table_1.column.key]
  }
}
table "some_table_2" { /* name for reference */
  name = "some_table" /* actual table_name */
  schema = schema.some_schema_2
  column "my_key" { type = varchar(255) }
  column "value" { type = longtext }
  primary_key {
    columns = [table.some_table_2.column.my_key]
  }
  index "my_key" {
    unique  = true
    columns = [table.some_table_2.column.my_key]
  }
}
schema "some_schema_1" {}
schema "some_schema_2" {}

from atlas.

rotemtam avatar rotemtam commented on September 24, 2024

@marxus thanks for reporting this. I'm aware of this issue which results from the way we load symbols into the HCL context for parsing. We will work on this and update

from atlas.

rotemtam avatar rotemtam commented on September 24, 2024

hey @marxus,

This issue is solved by recent work we did on supporting qualifiers for tables. You can read about it in the doc change.

You can get the latest (canary) version of atlas using brew:

brew upgrade ariga/tap/atlas

Consider a situation where we have two schema a and b, and both of them contain a table named users, with schema qualifiers if you run:

atlas schema inspect -d "mysql://root:pass@localhost:3306/" --schema a --schema b

You get:

table "a" "users" {
  schema = schema.a
  column "id" {
    null = true
    type = int
  }
}
table "b" "users" {
  schema = schema.b
  column "id" {
    null = true
    type = int
  }
}
schema "a" {
  charset = "utf8mb4"
  collate = "utf8mb4_0900_ai_ci"
}
schema "b" {
  charset = "utf8mb4"
  collate = "utf8mb4_0900_ai_ci"
}

As you see the table names are qualified with a prefix table "a" "users" and table "b" "users".

HTH

Closing this, let me know if you need anything else.

from atlas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.