Search code examples
djangodjango-modelsdjango-migrations

Delete unapplied migrations Django


I modified a model field in my local environment and made the migrations. Every thing seemed fine until I pushed it to production. I tried to apply the migrations to my DB and received an error:

cannot ALTER TABLE because it has pending trigger events

I ended up just reverting to the previous migration, which solved the problem for now.

But now I have these unapplied migration files pending and I need to find a way to either delete them or ignore them. What is the best solution moving forward?

Local

Production


Solution

  • You can fake the problematic migration (documentation here) - and then run the rest of the migrations.

    Should be:

    python manage.py migrate --fake 000x_problematic_migration
    

    And then run the rest of the migrations

    python manage.py migrate