4 ms·
ASK HN: Why Database migrations aren't handled like Git?
In DB migrations you write SQL statements so database can be modified to a new state. Without having to delete the table and write new CREATE TABLE....
You basically write how to change state.
In Git, you change the file and git internally figures out what has changed and then creates a commit. If you push it and then others download the changes they also reach to new state without having to delete everything. Only difference is..
You made changes to final state and Git automatically detected what changed. Git figures out how to change the state.
What you do in DB migration is equivalent to typing out Git commits manually on what files to change and how to change them.
Ex: Delete lines 22-30 in file abc.js and new lines at 10-15 which are .................. Instead of you just editing the abc.js.
See how stupid that looks. That's how stupid SQL migrations look to me.
Instead of me just updating schema and have some program figure out changes and propagate them to related parties. I've to manually write what change and how it changed in SQL statements.
Benefit:
New Users wont have to run 3000 migrations they can start with final state.
Humans wont have to write migrations by hand and do more productive things with their limited lives.
- fabrixxm 9y agoLooks like Django migrations :-) https://docs.djangoproject.com/en/2.0/topics/migrations/ https://docs.djangoproject.com/en/2.0/topics/migrations/
- techsin101 9y agoso i actually didn't know about that, so thanks. But does new user have to run all migrations. Say i get the repo, would i have to do migrate... because in git i dont have to run all commits. i get the final state of repo.
- ljoshua 9y agoThere are solutions like that out there, and they work pretty well, but tend to also be pricey. See Red Gate's SQL Compare: https://www.red-gate.com/products/sql-development/sql-compare/ https://www.red-gate.com/products/sql-development/sql-compar...