Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What if I don't commit django migrations?

Tags:

django

We have been working on a django project for months. You know for a dev team, migrations conflicts happen many times. I searched a lot to look what others do with this kind of problem and got results:
What really annoys me about Django migrations
django migrations - workflow with multiple dev branches
Django Migrations and How to Manage Conflicts
How to avoid migration conflicts with other developers?
And many other articles about how to avoid and resolve migration conflicts.
I want to know what if we just ignore migration files and just don't commit them?
Any answer is appreciated.

like image 645
Ali Farhoudi Avatar asked Oct 17 '22 15:10

Ali Farhoudi


1 Answers

You should not ignore database migrations. The Django documentation makes this pretty clear (emphasis is mine):

The migration files for each app live in a “migrations” directory inside of that app, and are designed to be committed to, and distributed as part of, its codebase. You should be making them once on your development machine and then running the same migrations on your colleagues’ machines, your staging machines, and eventually your production machines.

The fact that you have migration conflicts is an indication that your multiple developers are all creating their migrations at different times, resulting in a different set of files. If you commit the migrations as you should, this will never be a problem.

However, if you plan on squashing migrations (e.g. you expect to have a lot of churn in your database schema during a development cycle), you might wait to commit the migrations until all of your database design work for that cycle is complete. But they should always get committed.

After that, everyone will have the same set of files and no more conflicts.

like image 164
Jonah Bishop Avatar answered Nov 15 '22 11:11

Jonah Bishop