How to reset south migrations to capture the current state of my django models

后端 未结 1 1748
一整个雨季
一整个雨季 2021-02-02 03:30

I have an app that currently has 35 south migrations. These take a while to go through when setting up a new deployment (we create new deployments often), and the app is continu

1条回答
  •  时光说笑
    2021-02-02 03:59

    I figured this out (wasn't too bad). To set up the migration reset, I do the following:

    rm /migrations/*
    python manage.py schemamigration  --initial
    python manage.py migrate  0001 --fake  --delete-ghost-migrations
    

    I commit the changes to the repository, and then for each deployment of the code elsewhere, run:

    python manage.py migrate  0001 --fake --delete-ghost-migrations
    

    Make sure you don't add anything new between the time you last migrated everywhere else and you reset things or the new 0001 migration won't match up with the schema!

    Caveats: See guettli's comment (and my responses)

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