Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible with custom user model with migrations #24

Closed
mboldt opened this issue Dec 22, 2015 · 4 comments · Fixed by #25
Closed

Incompatible with custom user model with migrations #24

mboldt opened this issue Dec 22, 2015 · 4 comments · Fixed by #25
Labels

Comments

@mboldt
Copy link
Contributor

mboldt commented Dec 22, 2015

Symptom: after upgrading from Django 1.7 to Django 1.8, when I run python manage.py test, it fails with:

  Creating tables...
    Creating table referrals_referral
    Creating table referrals_referralresponse
    Running deferred SQL...
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/mboldt/projects/myphotographer/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
    utility.execute()
  File "/home/mboldt/projects/myphotographer/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 346, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/mboldt/projects/myphotographer/env/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 30, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/home/mboldt/projects/myphotographer/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 394, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/mboldt/projects/myphotographer/env/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 74, in execute
    super(Command, self).execute(*args, **options)
  File "/home/mboldt/projects/myphotographer/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 445, in execute
    output = self.handle(*args, **options)
  File "/home/mboldt/projects/myphotographer/env/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 90, in handle
    failures = test_runner.run_tests(test_labels)
  File "/home/mboldt/projects/myphotographer/env/local/lib/python2.7/site-packages/django/test/runner.py", line 210, in run_tests
    old_config = self.setup_databases()
  File "/home/mboldt/projects/myphotographer/env/local/lib/python2.7/site-packages/django/test/runner.py", line 166, in setup_databases
    **kwargs
  File "/home/mboldt/projects/myphotographer/env/local/lib/python2.7/site-packages/django/test/runner.py", line 370, in setup_databases
    serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
  File "/home/mboldt/projects/myphotographer/env/local/lib/python2.7/site-packages/django/db/backends/base/creation.py", line 368, in create_test_db
    test_flush=not keepdb,
  File "/home/mboldt/projects/myphotographer/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 120, in call_command
    return command.execute(*args, **defaults)
  File "/home/mboldt/projects/myphotographer/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 445, in execute
    output = self.handle(*args, **options)
  File "/home/mboldt/projects/myphotographer/env/local/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 "/home/mboldt/projects/myphotographer/env/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 318, in sync_apps
    cursor.execute(statement)
  File "/home/mboldt/projects/myphotographer/env/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/home/mboldt/projects/myphotographer/env/local/lib/python2.7/site-packages/django/db/utils.py", line 98, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/mboldt/projects/myphotographer/env/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation "email_username_customuser" does not exist

I believe this to be because pinax-referrals is an unmigrated app with a dependency on a migrated app (the custom user model). Do you agree this is an issue? Are there plans to add migrations to pinax-referrals to support this use case? If not, do you know a workaround?

@mboldt
Copy link
Contributor Author

mboldt commented Jan 6, 2016

For what it's worth, I made the migrations with manage.py makemigrations referrals (which is not entirely obvious with the pinax parent package; Django seems inconsistent, sometimes requiring pinax.referrals, and in this case requiring just referrals).

@ossanna16
Copy link
Contributor

@mboldt Awesome, I'm glad you figured out a solution! Would you mind sending a patch for this for our pinax-referrals docs? I think it would be really useful to others who might run into the same problem. It would be greatly appreciated! :)

@mboldt
Copy link
Contributor Author

mboldt commented Jan 21, 2016

I hope to send a doc patch within the next week. (Sorry so slow to respond; I was on vacation.)

@ossanna16
Copy link
Contributor

@mboldt No worries! Thank you so much 😊 Hope you had a great vacation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants