How can I skip a migration with Django migrate command?

后端 未结 1 1028
死守一世寂寞
死守一世寂寞 2021-02-11 20:16

First, I am asking about Django migration introduced in 1.7, not south.

Suppose I have migrations 001_add_field_x, 002_add_field_y

相关标签:
1条回答
  • 2021-02-11 20:51

    You can use the --fake option.

    Once you revert to 0001 you can run

    python manage.py migrate <app> 0002 --fake
    

    and then run

    python manage.py migrate <app> #Optionally specify 0003 explicitly
    

    which would apply only 0003 in this case.

    If you do not want to follow this process for all the environment/other developers, you can just remove the migration files, and run a new makemigration, and commit that file - and yes, do run migrate with the --fake option

    docs: https://docs.djangoproject.com/en/3.1/ref/django-admin/#cmdoption-migrate-fake

    0 讨论(0)
提交回复
热议问题