Trying to run the initial migrate/syncdb command in an empty PostgreSQL database results in an error with message below.
This seems to be related to recent changes in Django migrations - the problem only seems to occur on Django 1.8. The root cause seems to be that the "words" app, which is unmigrated, depends on the auth app, which is migrated, and this is not allowed: foreign key constraints get created without the tables they depend upon.
Operations to perform:
Synchronize unmigrated apps: staticfiles, rest_framework, messages, words
Apply all migrations: admin, contenttypes, auth, sessions
Synchronizing apps without migrations:
Creating tables...
Creating table words_tag
Creating table words_word
Creating table words_definition
Creating table words_examplesentence
Creating table words_comparisongroup
Creating table words_comparisonexample
Running deferred SQL...
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/usr/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 25, in handle
call_command("migrate", **options)
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 120, in call_command
return command.execute(*args, **defaults)
File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/usr/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 179, in handle
created_models = self.sync_apps(connection, executor.loader.unmigrated_apps)
File "/usr/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 317, in sync_apps
cursor.execute(statement)
File "/usr/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/lib/python2.7/site-packages/django/db/utils.py", line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/lib/python2.7/site-packages/django/db/backends/utils.py", line 62, in execute
return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation "auth_user" does not exist
Trying to run the initial migrate/syncdb command in an empty PostgreSQL database results in an error with message below.
This seems to be related to recent changes in Django migrations - the problem only seems to occur on Django 1.8. The root cause seems to be that the "words" app, which is unmigrated, depends on the auth app, which is migrated, and this is not allowed: foreign key constraints get created without the tables they depend upon.