How to squash recent Django migrations?

前端 未结 4 1038
太阳男子
太阳男子 2020-12-28 11:35

In Django\'s migrations code, there\'s a squashmigrations command which: \"Squashes the migrations for app_label up to and including migratio

4条回答
  •  佛祖请我去吃肉
    2020-12-28 12:19

    [If you are using Django 1.8 and need to squash migrations partially]

    In Django 1.9 squash migrations command has the ability to squash migrations FROM-TO

    here is squashmigrations.py from Django 1.9 version https://github.com/django/django/blob/stable/1.9.x/django/core/management/commands/squashmigrations.py

    you need to

    • place it in your project, under /-package-/app-/management/commands/
    • rename to squashmigrations19.py
    • run ./manage.py squashmigrations19 -your-app- 0002 0003

提交回复
热议问题