ariga / entimport

A tool for generating Ent schema from SQL schema
Apache License 2.0
174 stars 49 forks source link

How to generate Ent schemas for whole Postgres DB #29

Closed kpeu3i closed 2 years ago

kpeu3i commented 2 years ago

In my DB I have a few schemas and when I run:

go run ariga.io/entimport/cmd/entimport -dsn "postgres://user:password@localhost:5432/db_name?sslmode=disable"

it generates Ent schemas only for the public schema. I know that I can specify search_path=<schema_name> in the DSN query. But again, I have tables with the same names but inside different schemas. How did it suppose to work?

zeevmoney commented 2 years ago

Hi @kpeu3i, thanks for reaching out,

ent multi-schema (named database) feature is enabled by a feature flag: https://entgo.io/docs/feature-flags#schema-config You can import all schemas separately, and rename the duplicates, then use this feature to interact with them.

Of course this is not an optimal solution, and I'll add to the roadmap a rename table feature or prefix schema name to table name (open for ideas).

kpeu3i commented 2 years ago

Got it! Thanks for the great tool and your feedback!