How to squash recent Django migrations?

前端 未结 4 1011
太阳男子
太阳男子 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:16

    You can just delete the migration files and run makemigrations again. If you have a dev deployment that uses these, you should migrate back to the one before the first one you delete.

    Also, it's probably a good idea to commit your code first, in case something goes wrong.

    Also:

    The slight complication with this is that if there's custom RunPython code, it won't be included in the new migration created by makemigrations

提交回复
热议问题