-
Hi 👋🏼 ! We're extending/replacing (refactoring) an existing software (Django-based) and recently started using entgo for new pieces where database is required. To be able to extend the schema with new entities and relations, we imported parts of the existing database into entgo entities like this: go run ariga.io/entimport/cmd/entimport \
-dsn "postgres://${DB_USERNAME}:${DB_PASSWORD}@localhost:${DB_PORT}/db?sslmode=disable" \
-tables "table1,table2,table3" So table1 through table3 are old, and we aded table4 and table5. This seems to be the trick, each table is essentially an entity in the existing system. Now, we're approaching first rollouts and are looking for ways to generate migration files of the new entities (table4 and table5) that we are added. I read about versioned migrations using Atlas, which seems to be nicer for prod than the auto-migrations, and the overall setup seems to work: as in, if I don't have anything, it'll create the migration file that we can apply. What's unclear to me is how or where we configure it, to add initial state. For context: we've setup the bits with But this also includes the entities (table1 through table3) I imported from the existing database. I tried dumping the existing structure, but then it complains about the Ideally, I would be able to use an export (from Thanks for helping! :) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 15 replies
-
(Of course) Made some progress after I posted this: pg_dump --schema-only ... > ./ent/migrate/migrations/TS_initial.sql Then generated the atlas migrate --dir "file://ent/migrate/migrations" hash But now, when I try to create my migration on top, I get a couple odd errors regarding syntax, etc..
This is due to |
Beta Was this translation helpful? Give feedback.
-
@till , I think baseline migration is what you need: https://atlasgo.io/blog/2022/09/05/announcing-migration-execution#moving-an-existing-project-to-atlas-with-baseline-migrations |
Beta Was this translation helpful? Give feedback.
@till , I think baseline migration is what you need: https://atlasgo.io/blog/2022/09/05/announcing-migration-execution#moving-an-existing-project-to-atlas-with-baseline-migrations