4 ms·
that is not a viable practice over the long run. the entire point of using a migrations tool is so you can migrate the schema and the data forwards and backward
by metaphorm 14y ago
that is not a viable practice over the long run. the entire point of using a migrations tool is so you can migrate the schema and the data forwards and backwards automatically and consistently every time. attempting to do that with raw SQL scripts is a disaster waiting to happen. its so bad that the entire idea of a migration tool was invented to solve this problem.
so I ask again: what's your alternative (given that avoiding raw SQL scripts is the problem you're trying to solve)?
- mattdeboard 14y agoI'm getting sucked into an argument I don't really care about because I actually like South and use it in production for some things. But I mean idempotent SQL takes care of the vast majority of all this stuff you mentioned. Write your SQL properly and it doesn't matter whether or not it's been applied before.
- mh- 14y agoI don't know about postgres offhand, but there aren't idempotent solutions to some DDL operations in mysql. (alter table add column, off the top of my head)
- mattdeboard 14y agoYeah in Postgres you can check for the existence of a column in a table. If it exists/doesn't exist you can drop/add the column. Obviously "ALTER TABLE x ADD COLUMN y" isn't idempotent, but the whole SQL statement around it can be idempotent.