0👍
Have you tried migrating backward instead of forward?
<app_label> <migrationname>
: Brings the database schema to a state where the named migration is applied, but no later migrations in the same app are applied. This may involve unapplying migrations if you have previously migrated past the named migration. Use the name zero to unapply all migrations for an app.
My guess is that the makemigrations
command scans a model’s permissions meta, and produce a ‘insert’ SQL in Permission table for each missing permssion, it doesn’t actually do two-way synchronization in the migration script.
But the migration script can revert the changes with a ‘delete’ statement for every ‘insert’.
So try:
python manage.py migrate the_app the_migration_before_the_last
If this doesn’t work either, submit a bug to Django project.