
ASK HN: Why Database migrations aren't handled like Git? - techsin101
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....<p>You basically write how to change state.<p>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..<p>You made changes to final state and Git automatically detected what changed. Git figures out how to change the state.<p>What you do in DB migration is equivalent to typing out Git commits manually on what files to change and how to change them.<p>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.<p>See how stupid that looks. That&#x27;s how stupid SQL migrations look to me.<p>Instead of me just updating schema and have some program figure out changes and propagate them to related parties. I&#x27;ve to manually write what change and how it changed in SQL statements.<p>Benefit:<p>New Users wont have to run 3000 migrations they can start with final state.<p>Humans wont have to write migrations by hand and do more productive things with their limited lives.
======
ljoshua
There 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-compar...](https://www.red-gate.com/products/sql-
development/sql-compare/)

------
fabrixxm
Looks like Django migrations :-)

[https://docs.djangoproject.com/en/2.0/topics/migrations/](https://docs.djangoproject.com/en/2.0/topics/migrations/)

~~~
techsin101
so 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.

