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

后端 未结 15 1553
离开以前
离开以前 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:49
    1. In MySQL Database delete row 'profiles' from the table 'django_migrations'.
    2. Delete all migration files in migrations folder.
    3. Try again python manage.py makemigrations and python manage.py migrate command.
    0 讨论(0)
  • 2020-11-28 21:50

    In my case I wrote like this:

    python manage.py makemigrations --empty yourappname

    python manage.py migrate yourappname

    or:

    Django keeps track of all the applied migrations in django_migrations table. So just delete all the rows in the django_migrations table that are related to you app like:

    DELETE FROM django_migrations WHERE app='your-app-name'

    and then do:

    python manage.py makemigrations python manage.py migrate

    0 讨论(0)
  • 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

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