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).
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 the0002_remove_content_type_name
migration is applied.Making the first migrations of
contrib.auth
andcontrib.admin
dependant on0002_remove_content_type_name
solves the issue for those apps, but not necessarily for all apps that use content types.