How to merge consecutive database migrations in django 1.9+?

I want to run makemigrations but do not want a new migration to be created because the previous migrations haven't been used yet

This is not a problem, Django runs migrations from top to bottom, meaning: your latest migration file will wait until other previous migration files are ran.

because running each migration in production can take a lot of time when there is a lot of data in the database

How much data do you have in the database? If really much, then you must already have replications and redundant db servers. In this case, switch the reads and writes to one, say slave server, run the migrations in the master. and then switch the traffic back to master, and before that make sure that the lag between them is 0 and new schema is replicated properly among them


The command you are looking for is squashmigrations. It will merge all the unapplied migrations of a given app into a single file.