4 ms·
I use migra [https://databaseci.com/docs/migra https://databaseci.com/docs/migra] for PostgreSQL. I only put schema.sql into git, no migration scripts. To mak
by LittlePeter 5y ago
I use migra [https://databaseci.com/docs/migra https://databaseci.com/docs/migra] for PostgreSQL.
I only put schema.sql into git, no migration scripts.
To make changes, I update schema.sql and load it up into temporary db. Then I run migra prod_db temp_db and it spits out the SQL statements that take me from the old schema.sql (which was in production) to the new. I eyeball the statements and if they look good, I apply them to prod_db.
Is Atlas able to handle foreign key definitions with ON UPDATE RESTRICT ON DELETE RESTRICT clause? Can it handle ID columns auto generate default always? Does it allow for constraints like check(airport_code = upper(airport_code))? The screenshots show rather simple SQL stuff.
How
- majkinetor 5y agoYou eyeball the statements? Thats 100% unreliable, I'll just wait for your sugar to go down while you do that. Migration that is not automatic is not an option.
- LittlePeter 5y agoYes, I eyeball the migration code. You could call it code review, whatever. There is no way I am running migration code automatically. In fact I am not sure what you mean by "automatically"? As in a non-human triggers the migration? But do you review the code? First of all, migrations do not happen in my case that often that I need them to run unattended/automatically. Second, I don't trust any migration system to spit out flawless code. Maybe I have trust issues.
- majkinetor 5y agoIf migrations are rare, you are supporting old system. Migrations are there every few days on my projects. Non automatic migration is IMO not a migration but database intervention, just as non-automatic tests are not really tests.
- mvc 5y agoThis is the first I'd heard of migra but I can definitely imagine a solution involving piping the schema-diff between two databases (e.g. uat and local-dev) into some file that eventually gets applied in prod. Seems easier than manually creating diffs which is what existing automatated migration tools seem to want you to do. I love that it's just the diff. Makes it easier to integrate into cloud-native pipelines.