49 lines
1.3 KiB
Markdown
49 lines
1.3 KiB
Markdown
I try different commands and some of the answers help me. Only this sequence in my case fixed both broken dependencies in migrations in MYAPP and clean all past migrations starting from scratch.
|
|
|
|
Before doing this ensure that database is already synced (e.g. do not add a new Model field here or change Meta options).
|
|
|
|
rm -Rf MYAPP/migrations/*
|
|
python manage.py makemigrations --empty MYAPP
|
|
python manage.py makemigrations
|
|
python manage.py migrate --fake MYAPP 0002
|
|
Where 0002 is the migration number returned by the last makemigrations command.
|
|
|
|
Now you can run makemigrations / migrate again normally because migration 0002 is stored but not reflected in the already-synced database.
|
|
|
|
if you really want to go crazy delete all the tables in teh database related to the app and then
|
|
|
|
DELETE FROM django_migrations WHERE app='registry'
|
|
|
|
|
|
|
|
-------
|
|
|
|
|
|
this is what I do
|
|
|
|
first I clear out everything:
|
|
|
|
rm -Rf appname/migrations
|
|
|
|
fab database.drop_all
|
|
fab database.init
|
|
fab django.manage:migrate
|
|
fab django.manage:syncdb
|
|
|
|
|
|
then I re-add the app
|
|
|
|
fab django.manage:"makemigrations appname"
|
|
fab django.manage:migrate
|
|
|
|
|
|
at that point I have working table
|
|
so again
|
|
|
|
rm -Rf {ON HOST}/appname/migrations
|
|
fab ONHOST database.drop_all
|
|
fab ONHOST database.init
|
|
fab ONHOST deploy.sync <--- CRITICAL STEP DO NOT FORGET
|
|
fab ONHOST django.manage:migrate
|
|
fab ONHOST django.manage:syncdb
|
|
|