I have developed a Django 1.8 project a while ago. I deployed the project a few months back and everything was running perfectly. Today, I had to make a change in the database, but when I tried to run python manage.py makemigrations
, I got the message "No changes detected". I then noticed that there was no migration folder in any of the apps of the project. What I don't understand is:
makemigrations
then migrate
) when I first deployed the project, and everything was ok. I didn't check that the migration folders were there though. When I run python manage.py showmigrations
, I get the following:
admin
[X] 0001_initial
auth
[X] 0001_initial
[X] 0002_alter_permission_name_max_length
[X] 0003_alter_user_email_max_length
[X] 0004_alter_user_username_opts
[X] 0005_alter_user_last_login_null
[X] 0006_require_contenttypes_0002
contenttypes
[X] 0001_initial
[X] 0002_remove_content_type_name
sessions
[X] 0001_initial
This is the full output. No sign of any of my apps.
So my questions are the following:
Apps are allowed to have no migrations. Only apps with a migrations/__init__.py
file are considered to have migrations. manage.py makemigrations
won't create migrations for unmigrated apps unless you explicitly pass the app name. On Django 1.7/1.8, the tables are still created automatically through the old syncdb mechanism -- starting on Django 1.9, this requires the --syncdb
flag when migrating.
Now you need to get your migrations in sync with your database. For this, you need to:
manage.py migrate
.manage.py makemigrations <app_label>
to create an initial migration that matches your current database.manage.py migrate --fake-initial <app_label>
to mark the new migration as applied. After running these steps for each app your migrations should be in sync with your database, so you can now edit your models and create new migrations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With