Incomplete Fix for #24628 - Squashed Migration Still Not Marked as Applied
I'm still seeing this behavior in 1.8.3 so I believe that this fix is incomplete. The problem with the original fix is that it relies on the executor.migrate
method being called. While that is done by the tests, it isn't when following the workflow described in the docs. When you call the migrate
management command, it first checks the migration plan to see if any migrations need to be run. Since the migration plan sees the replacement migration as already applied there is no plan (assuming there are no other unapplied migrations) and the executor.migrate
is never called. In this case the replacement migration is never recorded as applied. Then when the old migrations are removed and the replaces
attribute is removed, the migrate
command attempts to run the squashed migration which fails since the tables, etc already exist.
The easiest work-around is to use the
--fake-initial
option when applying the squashed migration. This assumes that you are squashing the migrations down to a single initial migration.