Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#23008 closed Bug (fixed)

Migrations depending on django.contrib.auth with custom User model fail

Reported by: Ilya Semenov Owned by: nobody
Component: Migrations Version: 1.7-rc-1
Severity: Release blocker Keywords:
Cc: Andrew Godwin, Florian Apolloner Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Steps to reproduce:

  1. Create a new project and the new app accounts
  2. Create the model accounts.User:
    from django.contrib.auth import models as auth_models
    from django.db import models
    
    class User(auth_models.AbstractBaseUser, auth_models.PermissionsMixin):
            name = models.CharField(max_length=255, unique=True)
            USERNAME_FIELD = 'name'
    
  3. Edit settings.py and set AUTH_USER_MODEL = 'accounts.User'
  4. Run manage.py makemigrations accounts. It will crash:
    ...
      File "/Users/semenov/work/migrtest/venv/src/django/django/db/migrations/graph.py", line 42, in add_dependency
        raise KeyError("Dependency references nonexistent parent node %r" % (parent,))
    KeyError: u"Dependency references nonexistent parent node (u'auth', u'__last__')"
    

This started to happen 2 days ago, I bisected the cause to aba75e73db6a0baca1b721698ca24f026bb4a745 (the fix for #22970). Previously, the migration dependencies were set to [('auth', '__first__')] which worked fine. (I realize that __last__ makes more sense, so this is not about reverting the fix but rather making __last__ to work on django.contrib.auth.migrations.)

Change History (7)

comment:1 by Tim Graham, 10 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

makemigrations works fine for me, it's not until migrate that I get the error.

comment:2 by Ilya Semenov, 10 years ago

My bad, that's right, it's migrate that fails.

comment:3 by Tim Graham, 10 years ago

#23021 reported this for contenttypes.

comment:4 by Florian Apolloner, 10 years ago

Cc: Andrew Godwin Florian Apolloner added

This seems to be caused by the fact that we have 'last' and 'latest'. (Changing the file to 'latest' makes migrate work fine). @andrew: Which of the two did you intend in the beginning?

Version 0, edited 10 years ago by Florian Apolloner (next)

comment:5 by Andrew Godwin, 10 years ago

Yeah, it's meant to be __latest__, error on my part in the fix for the previous bug. Will fix it tonight if nobody gets there first.

comment:6 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: newclosed

In 9a2ab629776735fae2c9184dc4b9d9029bad15b2:

Fixed #23008 -- Fixed typo causing bad migration dependencies.

Thanks semenov for the report and Florian for investigation.

comment:7 by Tim Graham <timograham@…>, 10 years ago

In fe5f29eb1db795257d4095df0e1547c17daadade:

[1.7.x] Fixed #23008 -- Fixed typo causing bad migration dependencies.

Thanks semenov for the report and Florian for investigation.

Backport of 9a2ab62977 from master

Note: See TracTickets for help on using tickets.
Back to Top