Opened 8 years ago

Closed 8 years ago

#27424 closed Bug (needsinfo)

contenttype 0002_remove_content_type_name migration failure

Reported by: Juan Borda Owned by: nobody
Component: contrib.contenttypes Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

django/contrib/contenttype/migrations/0002_remove_content_type_name.py

In a project that uses django 1.8 we triend to run some tests and got failures when django tried to set up the databse from scratch.
We then traced this problem to a problem applying migration 0002_remove_content_type_name.py

the somewhat cryptic stacktrace follows:

  Rendering model states... DONE
  Applying contenttypes.0002_remove_content_type_name...Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/juanborda/.virtualenvs/sabios/lib/python3.5/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/home/juanborda/.virtualenvs/sabios/lib/python3.5/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/juanborda/.virtualenvs/sabios/lib/python3.5/site-packages/django/core/management/base.py", line 393, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/juanborda/.virtualenvs/sabios/lib/python3.5/site-packages/django/core/management/base.py", line 444, in execute
    output = self.handle(*args, **options)
  File "/home/juanborda/.virtualenvs/sabios/lib/python3.5/site-packages/django/core/management/commands/migrate.py", line 221, in handle
    executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
  File "/home/juanborda/.virtualenvs/sabios/lib/python3.5/site-packages/django/db/migrations/executor.py", line 110, in migrate
    self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial)
  File "/home/juanborda/.virtualenvs/sabios/lib/python3.5/site-packages/django/db/migrations/executor.py", line 148, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/home/juanborda/.virtualenvs/sabios/lib/python3.5/site-packages/django/db/migrations/migration.py", line 115, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/home/juanborda/.virtualenvs/sabios/lib/python3.5/site-packages/django/db/migrations/operations/special.py", line 178, in database_forwards
    if router.allow_migrate(schema_editor.connection.alias, app_label, **self.hints):
  File "/home/juanborda/.virtualenvs/sabios/lib/python3.5/site-packages/django/db/utils.py", line 347, in allow_migrate
    allow = method(db, app_label, **hints)
TypeError: allow_migrate() missing 1 required positional argument: 'model'

We overcame this by deleting the file and re-generating the migration.
this freshly created migration now allows us to create virgin databases as well as setup the test environment.

Atached is the new generated migration file that hopefull you can include in future packaged versions of 1.8 django or any others that might have this problem.

Attachments (1)

0002_remove_content_type_name.py (524 bytes ) - added by Juan Borda 8 years ago.
the newly generated migration file

Download all attachments as: .zip

Change History (2)

by Juan Borda, 8 years ago

the newly generated migration file

comment:1 by Simon Charette, 8 years ago

Resolution: needsinfo
Status: newclosed

Hi Juan,

Thanks for your report.

From your provided traceback it looks like you are not using the latest minor version of Django 1.8 so it's kind of hard to figure out whether or not Django is at fault.

From what I can see one of your database routers' allow_migrate() method have the incorrect signature. The signature changed in Django 1.8 but there's code in place to make sure the old signature works until Django 1.10.

Please try upgrading to the latest Django 1.8 release and re-open this ticket with details about the Python version you are using and the definition of your database routers the DATABASE_ROUTERS is pointing to.

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