Commit bed504d7 authored by Loic Bistuer's avatar Loic Bistuer
Browse files

Fixed #24351, #24346 -- Changed the signature of allow_migrate().

The new signature enables better support for routing RunPython and
RunSQL operations, especially w.r.t. reusable and third-party apps.

This commit also takes advantage of the deprecation cycle for the old
signature to remove the backward incompatibility introduced in #22583;
RunPython and RunSQL won't call allow_migrate() when when the router
has the old signature.

Thanks Aymeric Augustin and Tim Graham for helping shape up the patch.

Refs 22583.
parent dd0b4878
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ def create_permissions(app_config, verbosity=2, interactive=True, using=DEFAULT_
    except LookupError:
        return

    if not router.allow_migrate(using, Permission):
    if not router.allow_migrate_model(using, Permission):
        return

    from django.contrib.contenttypes.models import ContentType
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ def update_contenttypes(app_config, verbosity=2, interactive=True, using=DEFAULT
    except LookupError:
        return

    if not router.allow_migrate(using, ContentType):
    if not router.allow_migrate_model(using, ContentType):
        return

    ContentType.objects.clear_cache()
+1 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ class Migration(migrations.Migration):
        migrations.RunPython(
            migrations.RunPython.noop,
            add_legacy_name,
            hints={'model_name': 'contenttype'},
        ),
        migrations.RemoveField(
            model_name='contenttype',
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ def create_default_site(app_config, verbosity=2, interactive=True, using=DEFAULT
    except LookupError:
        return

    if not router.allow_migrate(using, Site):
    if not router.allow_migrate_model(using, Site):
        return

    if not Site.objects.using(using).exists():
+1 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ class Options(object):
        self.abstract = False
        self.managed = True
        self.proxy = False
        self.swapped = False


class BaseDatabaseCache(BaseCache):
Loading