4 ms·
> Finally, all migrations must be idempotent. That must be tough. Are you doing it by simply checking a "I've already done this flag"?
by ars 11y ago
> Finally, all migrations must be idempotent.
That must be tough. Are you doing it by simply checking a "I've already done this flag"?
- ansible 11y agoYou'd have a database table where its entire contents explain what's been done to the database schema and the data migrations. And then you make inserting a row named '3-add_customers_table' as part of the transaction for the migration. If this row already exists, the insert will fail, aborting the entire transaction. Or something like that...
- daigoba66 11y agoIf your RDBMS supports transactional DDL and conditionals then it is pretty simple. E.g. adding a column: IF NOT EXISTS ... ALTER TABLE ... ADD ...;