Django 1.7 - “No migrations to apply” when run migrate after makemigrations

后端 未结 15 1569
离开以前
离开以前 2020-11-28 20:46

I use Django1.7 with Mezzanine. I create simple profile (according to Mezzanine documentation) stored in separate app \"profiles\":

class RoadmapProfile(mode         


        
15条回答
  •  醉酒成梦
    2020-11-28 21:51

    This is a very confusing topic. django stores all applied migrations in a table called django_migrations. perform this sql ( i am using postgres . so in query tool section)

    select * from django_migrations where app='your appname'  (app in which u have issue with).
    

    This will list all applied migrations for that app.
    Go to your app/migration folder and check all migrations . find the migration file associated with your error . file where your table was created or column added or modified.
    look for the id of this migration file in django_migrations table( select * from django_migrations where app='your app') .

    Then do :

    delete from django_migrations where id='id of your migration';
    

    delete multiple id's if you have multiple migrations file associated with your issue.

    now reapply migrate

    Python manage.py migrate yourappname
    

    second option

    1. Drop tables in your app where you have issue.

    2. delete all migrations for that app from app/migrations folder.(don't delete init.py from that folder).

    3. now run

      python manage.py makemigrations appname

    4. now run

    python manage.py migrate appname

提交回复
热议问题