3 ms·
I used this tool very successfully to auto-generate migrations. 1) I maintain "schema.sql" file that contains the schema I want to have 2) That file then is ra
by Inviz 5y ago
I used this tool very successfully to auto-generate migrations.
1) I maintain "schema.sql" file that contains the schema I want to have
2) That file then is ran in a temporary empty database
3) Migra would run to compare old version of dev database against temporary database
4) Output of migra is wrapped into a conditional that has a guard check to see if database is already migrated to that version (as determined by timestamp in table description) and put into a file with timestamp as a name
5) Each time app restarts it scans all migrations in the directory and runs ones that it thinks it needs to run
Either way i had zero issues with this setup. And I used a lot of postgres things including triggers, complex indecies, extensions, etc. All migrations were source-controlled and could be verified before commits, so it was pretty safe. When I needed to migrate a data, i'd just add code into the same migration file as the schema change. Brilliant project! thanks @djrobstep