[Django] #24299: `migrate auth` throws django.db.utils.IntegrityError

14 views
Skip to first unread message

Django

unread,
Feb 7, 2015, 3:45:21 PM2/7/15
to django-...@googlegroups.com
#24299: `migrate auth` throws django.db.utils.IntegrityError
----------------------------+--------------------
Reporter: sir-sigurd | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------
do `migrate auth` on clean DB


{{{
Operations to perform:
Apply all migrations: auth
Running migrations:
Rendering model states... DONE
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 338, in
execute_from_command_line
utility.execute()
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/core/management/base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/core/management/commands/migrate.py", line 217, in handle
emit_post_migrate_signal(created_models, self.verbosity,
self.interactive, connection.alias)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/core/management/sql.py", line 280, in
emit_post_migrate_signal
using=db)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/dispatch/dispatcher.py", line 201, in send
response = receiver(signal=self, sender=sender, **named)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/contrib/auth/management/__init__.py", line 87, in
create_permissions
ctype = ContentType.objects.db_manager(using).get_for_model(klass)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/contrib/contenttypes/models.py", line 78, in get_for_model
model=opts.model_name,
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/db/models/manager.py", line 127, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/db/models/query.py", line 404, in get_or_create
return self._create_object_from_params(lookup, params)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/db/models/query.py", line 444, in
_create_object_from_params
six.reraise(*exc_info)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/db/models/query.py", line 436, in
_create_object_from_params
obj = self.create(**params)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/db/models/query.py", line 345, in create
obj.save(force_insert=True, using=self.db)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/db/models/base.py", line 696, in save
force_update=force_update, update_fields=update_fields)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/db/models/base.py", line 724, in save_base
updated = self._save_table(raw, cls, force_insert, force_update,
using, update_fields)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/db/models/base.py", line 808, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk,
raw)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/db/models/base.py", line 847, in _do_insert
using=using, raw=raw)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/db/models/manager.py", line 127, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/db/models/query.py", line 917, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/db/models/sql/compiler.py", line 964, in execute_sql
cursor.execute(sql, params)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/db/backends/utils.py", line 80, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/db/utils.py", line 95, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/sergey/tmp/django-fk/local/lib/python2.7/site-
packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: null value in column "name" violates not-
null constraint
DETAIL: Failing row contains (1, null, auth, permission).
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24299>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 7, 2015, 4:08:42 PM2/7/15
to django-...@googlegroups.com
#24299: `migrate auth` throws django.db.utils.IntegrityError
----------------------------+------------------------------------

Reporter: sir-sigurd | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------
Changes (by MarkusH):

* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/24299#comment:1>

Django

unread,
Feb 8, 2015, 8:30:18 PM2/8/15
to django-...@googlegroups.com
#24299: `migrate auth` throws django.db.utils.IntegrityError
----------------------------+-------------------------------------

Reporter: sir-sigurd | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.8alpha1

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+-------------------------------------
Changes (by knbk):

* version: master => 1.8alpha1


Comment:

The removel of `ContentType.name` as a field in
b4ac23290772e0c11379eb2dfb81c750b7052b66 introduced this bug in 1.8.
`ContentType.get_for_model` can't be used at all for non-existing content
types until the `0002_remove_content_type_name` migration is applied.

Making the first migrations of `contrib.auth` and `contrib.admin`
dependant on `0002_remove_content_type_name` solves the issue for those
apps, but not necessarily for all apps that use content types.

--
Ticket URL: <https://code.djangoproject.com/ticket/24299#comment:2>

Django

unread,
Feb 9, 2015, 6:17:41 PM2/9/15
to django-...@googlegroups.com
#24299: `migrate auth` throws django.db.utils.IntegrityError
----------------------------+-------------------------------------

Reporter: sir-sigurd | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.8alpha1
Severity: Normal | Resolution:
Keywords: 1.8-beta | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+-------------------------------------
Changes (by timgraham):

* keywords: => 1.8-beta
* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/24299#comment:3>

Django

unread,
Feb 11, 2015, 11:35:32 AM2/11/15
to django-...@googlegroups.com
#24299: `migrate auth` throws django.db.utils.IntegrityError
----------------------------+-------------------------------------

Reporter: sir-sigurd | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.8alpha1
Severity: Normal | Resolution:
Keywords: 1.8-beta | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+-------------------------------------
Changes (by timgraham):

* needs_tests: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/24299#comment:4>

Django

unread,
Feb 16, 2015, 1:37:37 PM2/16/15
to django-...@googlegroups.com
#24299: `migrate auth` throws django.db.utils.IntegrityError
----------------------------+-------------------------------------

Reporter: sir-sigurd | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.8alpha1
Severity: Normal | Resolution:
Keywords: 1.8-beta | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"d392c1e150a46aca72e37263c44c034d92a79f79"]:
{{{
#!CommitTicketReference repository=""
revision="d392c1e150a46aca72e37263c44c034d92a79f79"
Refs #24299 -- Made contenttypes migrations signal handler more robust.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24299#comment:5>

Django

unread,
Feb 16, 2015, 1:44:24 PM2/16/15
to django-...@googlegroups.com
#24299: `migrate auth` throws django.db.utils.IntegrityError
----------------------------+-------------------------------------

Reporter: sir-sigurd | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.8alpha1
Severity: Normal | Resolution:
Keywords: 1.8-beta | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"870d900cdcd29564bcc7f47cc67d51af2617f614"]:
{{{
#!CommitTicketReference repository=""
revision="870d900cdcd29564bcc7f47cc67d51af2617f614"
[1.8.x] Refs #24299 -- Made contenttypes migrations signal handler more
robust.

Backport of d392c1e150a46aca72e37263c44c034d92a79f79 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24299#comment:6>

Django

unread,
Feb 16, 2015, 1:50:52 PM2/16/15
to django-...@googlegroups.com
#24299: `migrate auth` throws django.db.utils.IntegrityError
----------------------------+-------------------------------------

Reporter: sir-sigurd | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.8alpha1
Severity: Normal | Resolution:
Keywords: 1.8-beta | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+-------------------------------------

Comment (by timgraham):

Markus suggested to also [https://github.com/django/django/pull/4150 add a
migration] to ensure all contenttypes 0002 is applied before sending the
post_migrate signal for auth.

--
Ticket URL: <https://code.djangoproject.com/ticket/24299#comment:7>

Django

unread,
Feb 16, 2015, 2:55:32 PM2/16/15
to django-...@googlegroups.com
#24299: `migrate auth` throws django.db.utils.IntegrityError
----------------------------+-------------------------------------
Reporter: sir-sigurd | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.8alpha1
Severity: Normal | Resolution: fixed

Keywords: 1.8-beta | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"4538cbf17d4391cda22d76bc6ac69f228f7400f2"]:
{{{
#!CommitTicketReference repository=""
revision="4538cbf17d4391cda22d76bc6ac69f228f7400f2"
Fixed #24299 -- Added an auth migration to ensure contenttypes is
migrated.

Without this migration, the auth signal handlers will fail if migrating
only auth.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24299#comment:8>

Django

unread,
Feb 16, 2015, 2:56:30 PM2/16/15
to django-...@googlegroups.com
#24299: `migrate auth` throws django.db.utils.IntegrityError
----------------------------+-------------------------------------
Reporter: sir-sigurd | Owner: nobody

Type: Bug | Status: closed
Component: Migrations | Version: 1.8alpha1
Severity: Normal | Resolution: fixed
Keywords: 1.8-beta | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"77e3f7dd586908b6c78d9718bbea65846e20e180"]:
{{{
#!CommitTicketReference repository=""
revision="77e3f7dd586908b6c78d9718bbea65846e20e180"
[1.8.x] Fixed #24299 -- Added an auth migration to ensure contenttypes is
migrated.

Without this migration, the auth signal handlers will fail if migrating
only auth.

Backport of 4538cbf17d4391cda22d76bc6ac69f228f7400f2 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24299#comment:9>

Reply all
Reply to author
Forward
0 new messages