4
votes

I am trying to do a migration in django 2.2.4 in python 3.7. First I try to make do makemigations:

python3 manage.py makemigrations

I get:

Migrations for 'main':
  main/migrations/0001_initial.py
    - Create model TutorialCategory
    - Create model TutorialSeries
    - Create model Tutorial

But then I try the second step:

python3 manage.py migrate

I get:

Operations to perform:
  Apply all migrations: admin, auth, contenttypes, main, sessions
Running migrations:
  No migrations to apply.

Even though a migration should happen.

I tried deleting my migrations folder and then remaking it (with the empty __init__.py file inside) but it still doesn't work.

(Note: I have been following along the tutorial: Linking models with Foreign Keys - Django Web Development with Python p.9 by sentdex)

2
Is this all running locally? Not on Heroku, for example? - Daniel Roseman
Yes it is running all locally. - user8802333

2 Answers

3
votes

I faced the same problem in django 2.2, The following worked for me...

  1. delete the migrations folder resided inside the app folder
  2. delete the pycache folder too
  3. restart the server [if your server is on and you are working from another cli]
  4. python manage.py makemigrations <app_name> zero
  5. python manage.py makemigrations <app_name> [explicit app_name is important]
  6. python manage.py migrate
2
votes

Somehow your migrations are virtually or faked applied in the database, Truncating django_migrations table should work.

  1. Delete all the migrations files:

    find . -path "/migrations/.py" -not -name "init.py" -delete find . -path "/migrations/.pyc" -delete

  2. Truncate table:

    truncate django_migrations

  3. makemigrations, migrate.