I started a django 1.8 project, which uses the migrations system.
Somehow along the way things got messy, so I erased the migrations folders and table from the DB, and now I'm trying to reconstruct them, with no success.
I have three apps (3 models.py
files), and the models reflect the tables EXACTLY!
The best approach that I've found so far was:
- Erase all
migrations
folders. Done! - Delete everything from the
django_migrations
table. Done! - Run
python manage.py makemigrations --empty <app>
for every app. Done! - Run
python manage.py migrate --fake
. Done! (although it works only if I run it after everymakemigrations
command.
Now I add a new field, run the makemigrations
command, and I receive the following error:
django.db.utils.OperationalError: (1054, "Unknown column 'accounts_plan.max_item_size' in 'field list'")
I've been burning HOURS on this thing. How the h**l can I initialize the migrations so I can continue working without migration interruptions every time?
Why is it so complicated? Why isn't there a simple one-liner: initiate_migrations_from_schema
?
EDIT:
Now things get even nastier. I truncated the django_migrations
table and deleted all the migrations
folder.
Now I try to run python manage.py migrate --fake-initial
(something I found in the DEV docs), just so it sets up all of Django's 'internal' apps (auth, session, etc) and I'm getting:
(1054, "Unknown column 'name' in 'django_content_type'")
.
Now, this "column" is not a real column. It's a @property
defined in Django's contenttypes
app. WHAT IS GOING ON HERE? Why is it identifying the name
property as a real column?