#24075: Can't migrate contenttypes and auth to zero
-------------------------------------------+------------------------
               Reporter:  apollo13         |          Owner:  nobody
                   Type:  Bug              |         Status:  new
              Component:  Migrations       |        Version:  master
               Severity:  Release blocker  |       Keywords:
           Triage Stage:  Unreviewed       |      Has patch:  0
    Needs documentation:  0                |    Needs tests:  0
Patch needs improvement:  0                |  Easy pickings:  0
                  UI/UX:  0                |
-------------------------------------------+------------------------
 Trying to migrate either auth to zero results in:
 {{{
 ./manage.py migrate -v3 auth zero
 Operations to perform:
   Unapply all migrations: auth
 Running pre-migrate handlers for application admin
 Running pre-migrate handlers for application auth
 Running pre-migrate handlers for application contenttypes
 Running pre-migrate handlers for application sessions
 Running migrations:
   Unapplying auth.0005_alter_user_last_login_null... OK (0.023s)
   Unapplying auth.0004_alter_user_username_opts... OK (0.013s)
   Unapplying auth.0003_alter_user_email_max_length... OK (0.015s)
   Unapplying auth.0002_alter_permission_name_max_length... OK (0.008s)
   Unapplying admin.0001_initial... OK (0.014s)
   Unapplying auth.0001_initial... OK (0.035s)
 Running post-migrate handlers for application admin
 Traceback (most recent call last):
   File "./manage.py", line 10, in <module>
     execute_from_command_line(sys.argv)
   File
 "/home/florian/sources/django.git/django/core/management/__init__.py",
 line 338, in execute_from_command_line
     utility.execute()
   File
 "/home/florian/sources/django.git/django/core/management/__init__.py",
 line 330, in execute
     self.fetch_command(subcommand).run_from_argv(self.argv)
   File "/home/florian/sources/django.git/django/core/management/base.py",
 line 391, in run_from_argv
     self.execute(*args, **cmd_options)
   File "/home/florian/sources/django.git/django/core/management/base.py",
 line 445, in execute
     output = self.handle(*args, **options)
   File
 "/home/florian/sources/django.git/django/core/management/commands/migrate.py",
 line 216, in handle
     emit_post_migrate_signal(created_models, self.verbosity,
 self.interactive, connection.alias)
   File "/home/florian/sources/django.git/django/core/management/sql.py",
 line 280, in emit_post_migrate_signal
     using=db)
   File "/home/florian/sources/django.git/django/dispatch/dispatcher.py",
 line 198, in send
     response = receiver(signal=self, sender=sender, **named)
   File
 "/home/florian/sources/django.git/django/contrib/auth/management/__init__.py",
 line 93, in create_permissions
     "content_type", "codename"
   File "/home/florian/sources/django.git/django/db/models/query.py", line
 164, in __iter__
     self._fetch_all()
   File "/home/florian/sources/django.git/django/db/models/query.py", line
 999, in _fetch_all
     self._result_cache = list(self.iterator())
   File "/home/florian/sources/django.git/django/db/models/query.py", line
 1254, in iterator
     for row in self.query.get_compiler(self.db).results_iter():
   File
 "/home/florian/sources/django.git/django/db/models/sql/compiler.py", line
 747, in results_iter
     for rows in self.execute_sql(MULTI):
   File
 "/home/florian/sources/django.git/django/db/models/sql/compiler.py", line
 831, in execute_sql
     cursor.execute(sql, params)
   File "/home/florian/sources/django.git/django/db/backends/utils.py",
 line 80, in execute
     return super(CursorDebugWrapper, self).execute(sql, params)
   File "/home/florian/sources/django.git/django/db/backends/utils.py",
 line 65, in execute
     return self.cursor.execute(sql, params)
   File "/home/florian/sources/django.git/django/db/utils.py", line 95, in
 __exit__
     six.reraise(dj_exc_type, dj_exc_value, traceback)
   File "/home/florian/sources/django.git/django/db/backends/utils.py",
 line 65, in execute
     return self.cursor.execute(sql, params)
 django.db.utils.ProgrammingError: relation "auth_permission" does not
 exist
 LINE 1: ...ntent_type_id", "auth_permission"."codename" FROM "auth_perm...
 }}}

 and migrating contenttypes to zero:
 {{{
 ./manage.py migrate -v3 contenttypes zero
 Operations to perform:
   Unapply all migrations: contenttypes
 Running pre-migrate handlers for application admin
 Running pre-migrate handlers for application auth
 Running pre-migrate handlers for application contenttypes
 Running pre-migrate handlers for application sessions
 Running migrations:
   Unapplying contenttypes.0001_initial... OK (0.029s)
 Running post-migrate handlers for application admin
 Traceback (most recent call last):
   File "./manage.py", line 10, in <module>
     execute_from_command_line(sys.argv)
   File
 "/home/florian/sources/django.git/django/core/management/__init__.py",
 line 338, in execute_from_command_line
     utility.execute()
   File
 "/home/florian/sources/django.git/django/core/management/__init__.py",
 line 330, in execute
     self.fetch_command(subcommand).run_from_argv(self.argv)
   File "/home/florian/sources/django.git/django/core/management/base.py",
 line 391, in run_from_argv
     self.execute(*args, **cmd_options)
   File "/home/florian/sources/django.git/django/core/management/base.py",
 line 445, in execute
     output = self.handle(*args, **options)
   File
 "/home/florian/sources/django.git/django/core/management/commands/migrate.py",
 line 216, in handle
     emit_post_migrate_signal(created_models, self.verbosity,
 self.interactive, connection.alias)
   File "/home/florian/sources/django.git/django/core/management/sql.py",
 line 280, in emit_post_migrate_signal
     using=db)
   File "/home/florian/sources/django.git/django/dispatch/dispatcher.py",
 line 198, in send
     response = receiver(signal=self, sender=sender, **named)
   File
 "/home/florian/sources/django.git/django/contrib/auth/management/__init__.py",
 line 82, in create_permissions
     ctype = ContentType.objects.db_manager(using).get_for_model(klass)
   File
 "/home/florian/sources/django.git/django/contrib/contenttypes/models.py",
 line 60, in get_for_model
     "Error creating new content types. Please make sure contenttypes "
 RuntimeError: Error creating new content types. Please make sure
 contenttypes is migrated before trying to migrate apps individually.
 }}}

 Not really sure how to best fix this, should the signal handlers check the
 migration table?

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.cd694ebd45d4d4a9db2c18e36f07db74%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to