[Answered ]-Django/ Python- should I run makemigrations on a local branch, or only on master?

2đź‘Ť

âś…

Generally, you would do a makemigrations on your development branch, and you would move the code (in this case, migration files) up to higher branches (UAT, Staging, Master etc).

This way you would never need to run makemigrations on any other branch, but only the migrate command.

You can have as many migration files as you need, it doesn’t really affect performance and is highly optimised

You can always squash/merge your migrations if there are too many or if you wish to do so.

See Squasing Migrations

👤at14

0đź‘Ť

Running makemigrations will automatically create python files in the “migrations” folder of the app where you modified the model. These files must be versionned in git because they cannot be dissociated from your modifications of the model.

Then, when you will merge your branch, both the modification in the model and the corresponding migration will be in the git tree. So the next call to migrate will synchronize the DB with the current state described by your models.

👤Antwane

Leave a comment