Ask HN: How do you handle data migrations in SQL databases?
There was a recent discussion about handling schema migrations (https://news.ycombinator.com/item?id=19880334). Following up on this, if you deploy a schema migration, sometimes there's a data migration that needs to follow. For example, I recently wanted to "promote" a field from a JSON column in a postgres database to a SQL table column. It's easy enough to add the new column, but what tools and patterns are out there for handling the data migration?
14 comments
[ 2.8 ms ] story [ 38.0 ms ] threadFor complex operations we use plain sql files.
Always test on staging with the live data and schema!
I'm curious how folks who aren't using an ORM handle this. We've used Goose before for schema migrations, and can add .go migrations that handle more complex data-migration tasks. It always feels more brittle, and I wonder if there's a pattern that I'm missing here. Is there a better way for non-ORM users to handle data migrations?
Noticed that it released its 1.0 a couple of days ago (https://github.com/sqitchers/sqitch).