Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#25686 closed Bug (fixed)

Database router without "allow_migrate" method raises exception

Reported by: Josep Cugat Owned by: nobody
Component: Database layer (models, ORM) Version: 1.8
Severity: Release blocker Keywords: allow_migrate
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

It seems Django 1.8.6 has introduced an error when using a database router that doesn't have a "allow_migrate" method. The router we are using is PinningMasterSlaveRouter, which has a "allow_syncdb" method but no "allow_migrate". This was working with Django 1.8.5 (as seen in #24532), and it seems that the commit which introduced this is e2ea30c.

The traceback:

./manage.py migrate
Traceback (most recent call last):
  File "./manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
    utility.execute()
  File "/opt/lib/python2.7/site-packages/django/core/management/__init__.py", line 346, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/lib/python2.7/site-packages/django/core/management/base.py", line 394, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/lib/python2.7/site-packages/raven/contrib/django/management/__init__.py", line 41, in new_execute
    return original_func(self, *args, **kwargs)
  File "/opt/lib/python2.7/site-packages/django/core/management/base.py", line 444, in execute
    self.check()
  File "/opt/lib/python2.7/site-packages/django/core/management/base.py", line 482, in check
    include_deployment_checks=include_deployment_checks,
  File "/opt/lib/python2.7/site-packages/django/core/checks/registry.py", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/opt/lib/python2.7/site-packages/django/core/checks/model_checks.py", line 28, in check_all_models
    errors.extend(model.check(**kwargs))
  File "/opt/lib/python2.7/site-packages/django/db/models/base.py", line 1207, in check
    errors.extend(cls._check_long_column_names())
  File "/opt/lib/python2.7/site-packages/django/db/models/base.py", line 1610, in _check_long_column_names
    if not router.allow_migrate_model(db, cls):
  File "/opt/lib/python2.7/site-packages/django/db/utils.py", line 367, in allow_migrate_model
    model=model,
  File "/opt/lib/python2.7/site-packages/django/db/utils.py", line 343, in allow_migrate
    argspec = inspect.getargspec(router.allow_migrate)
AttributeError: 'PinningMasterSlaveRouter' object has no attribute 'allow_migrate'

Change History (7)

comment:2 by Simon Charette, 9 years ago

Component: UncategorizedDatabase layer (models, ORM)
Has patch: set
Patch needs improvement: set
Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

Hi jcugat, thanks for spotting this issue.

Please rebase the patch on the 1.9.x branch (which also have this issue) and add a release note for the upcoming 1.8.x release. Commiters will take care of the backporting to 1.8.x and the release note forward porting to master. I guess a simple regression test wouldn't hurt here.

comment:3 by Josep Cugat, 9 years ago

Created a new PR #5557 because somehow github did not like the rebase...

comment:4 by Simon Charette, 9 years ago

Triage Stage: AcceptedReady for checkin

Only the release note will need to be backported to stable/1.9.x and the master branch since allow_syncdb support has been dropped in 1.9

comment:5 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: newclosed

In a42c537:

[1.8.x] Fixed #25686 -- Fixed crash on routers without an allow_migrate() method.

Thanks Simon Charette for review.

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

In c6da4b0c:

Refs #25686 -- Forwardported 1.8.7 release note.

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

In 6858bf7:

[1.9.x] Refs #25686 -- Forwardported 1.8.7 release note.

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