I am developing a large django-based project. On my laptop I use SQLite3 as a database. I have created a lot of migrations for my models. Everything seems working.
Then I want to use PostgreSQL on the production server. I have prepared an empty database and trying to do manage.py syncdb. And suddenly I get an error due to not existing relation.
Operations to perform:
Synchronize unmigrated apps: suit, messages, humanize, imagekit, staticfiles, crispy_forms, storages, django_extensions, localflavor, registration
Apply all migrations: [here list of my apps], sites, user_auth, sessions, auth
Synchronizing apps without migrations:
Creating tables...
Creating table registration_registrationprofile
Running deferred SQL...
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 62, in execute
return self.cursor.execute(sql)
psycopg2.ProgrammingError: relation "user_auth_account" does not exist
Trying to drop my sqlite database and perform syncdb with the new sqlite: it creates the schema without issues.
Here I've realized that SQLite does not use Foreign Key relations and simply uses integer types for all references. So it works for sqlite. Very smart, Django. But all my models are depending of each other. And I want to use different databases.
Now I have a bunch of migrations working on SQLite only.
I understand that it is possible to run migrations one-by-one for each application where the model first gets created. But it would be a hell.
Is it possible to detect dependencies and run these migrations in correct order?