3 ms·
Yep, a migration script (if you have data you care about) is very important, it should be reviewed before being excluded. It has the power to blow away your dat
by nhoughto 5y ago
Yep, a migration script (if you have data you care about) is very important, it should be reviewed before being excluded. It has the power to blow away your data if done poorly. So having an explicit SQL statement (whether hand crafted or generated and exported) that is visible is super important, it means you are thinking about this important step, so its visible and harder to forget.
The classic problem with letting your ORM manage migration is if you are updating your database entity model as part of a wider change, in your ORM and you rename a column, does it know its a rename? or is it going to DROP COLUMN + ADD COLUMN? and lead to data-loss? To cover these cases and all the infinite other permutation you end up needing to give the ORM more and more state about the past, making it just a more complex migration. Making the migration explicit SQL and decoupled from the ORM forces thought, a human is unlikely to write DROP COLUMN..