diff options
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/auth/management/__init__.py | 2 | ||||
| -rw-r--r-- | django/contrib/contenttypes/management.py | 2 | ||||
| -rw-r--r-- | django/contrib/gis/tests/layermap/tests.py | 2 | ||||
| -rw-r--r-- | django/contrib/sites/management.py | 2 | ||||
| -rw-r--r-- | django/core/management/commands/createcachetable.py | 2 | ||||
| -rw-r--r-- | django/core/management/commands/dumpdata.py | 2 | ||||
| -rw-r--r-- | django/core/management/commands/flush.py | 2 | ||||
| -rw-r--r-- | django/core/management/commands/loaddata.py | 2 | ||||
| -rw-r--r-- | django/core/management/commands/migrate.py | 2 | ||||
| -rw-r--r-- | django/db/backends/__init__.py | 6 | ||||
| -rw-r--r-- | django/db/utils.py | 7 |
11 files changed, 17 insertions, 14 deletions
diff --git a/django/contrib/auth/management/__init__.py b/django/contrib/auth/management/__init__.py index e1b9be2e9b..343828ec17 100644 --- a/django/contrib/auth/management/__init__.py +++ b/django/contrib/auth/management/__init__.py @@ -64,7 +64,7 @@ def create_permissions(app, created_models, verbosity, db=DEFAULT_DB_ALIAS, **kw except UnavailableApp: return - if not router.allow_syncdb(db, auth_app.Permission): + if not router.allow_migrate(db, auth_app.Permission): return from django.contrib.contenttypes.models import ContentType diff --git a/django/contrib/contenttypes/management.py b/django/contrib/contenttypes/management.py index 21a34b2bfa..4278bbd1e7 100644 --- a/django/contrib/contenttypes/management.py +++ b/django/contrib/contenttypes/management.py @@ -16,7 +16,7 @@ def update_contenttypes(app, created_models, verbosity=2, db=DEFAULT_DB_ALIAS, * except UnavailableApp: return - if not router.allow_syncdb(db, ContentType): + if not router.allow_migrate(db, ContentType): return ContentType.objects.clear_cache() diff --git a/django/contrib/gis/tests/layermap/tests.py b/django/contrib/gis/tests/layermap/tests.py index c4c27b353e..3b040624f3 100644 --- a/django/contrib/gis/tests/layermap/tests.py +++ b/django/contrib/gis/tests/layermap/tests.py @@ -311,7 +311,7 @@ class OtherRouter(object): def allow_relation(self, obj1, obj2, **hints): return None - def allow_syncdb(self, db, model): + def allow_migrate(self, db, model): return True diff --git a/django/contrib/sites/management.py b/django/contrib/sites/management.py index 3ab49e5482..d9e3a2126c 100644 --- a/django/contrib/sites/management.py +++ b/django/contrib/sites/management.py @@ -11,7 +11,7 @@ from django.core.management.color import no_style def create_default_site(app, created_models, verbosity, db, **kwargs): # Only create the default sites in databases where Django created the table - if Site in created_models and router.allow_syncdb(db, Site) : + if Site in created_models and router.allow_migrate(db, Site) : # The default settings set SITE_ID = 1, and some tests in Django's test # suite rely on this value. However, if database sequences are reused # (e.g. in the test suite after flush/syncdb), it isn't guaranteed that diff --git a/django/core/management/commands/createcachetable.py b/django/core/management/commands/createcachetable.py index d7ce3e93fd..27668f272d 100644 --- a/django/core/management/commands/createcachetable.py +++ b/django/core/management/commands/createcachetable.py @@ -24,7 +24,7 @@ class Command(LabelCommand): def handle_label(self, tablename, **options): db = options.get('database') cache = BaseDatabaseCache(tablename, {}) - if not router.allow_syncdb(db, cache.cache_model_class): + if not router.allow_migrate(db, cache.cache_model_class): return connection = connections[db] fields = ( diff --git a/django/core/management/commands/dumpdata.py b/django/core/management/commands/dumpdata.py index c5eb1b9a9e..5e440196fc 100644 --- a/django/core/management/commands/dumpdata.py +++ b/django/core/management/commands/dumpdata.py @@ -117,7 +117,7 @@ class Command(BaseCommand): for model in sort_dependencies(app_list.items()): if model in excluded_models: continue - if not model._meta.proxy and router.allow_syncdb(using, model): + if not model._meta.proxy and router.allow_migrate(using, model): if use_base_manager: objects = model._base_manager else: diff --git a/django/core/management/commands/flush.py b/django/core/management/commands/flush.py index 2ced3a2d60..a6ea45ce95 100644 --- a/django/core/management/commands/flush.py +++ b/django/core/management/commands/flush.py @@ -96,6 +96,6 @@ Are you sure you want to do this? for app in models.get_apps(): all_models.extend([ m for m in models.get_models(app, include_auto_created=True) - if router.allow_syncdb(database, m) + if router.allow_migrate(database, m) ]) emit_post_migrate_signal(set(all_models), verbosity, interactive, database) diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py index 6856e85e45..802226f9d1 100644 --- a/django/core/management/commands/loaddata.py +++ b/django/core/management/commands/loaddata.py @@ -133,7 +133,7 @@ class Command(BaseCommand): for obj in objects: objects_in_fixture += 1 - if router.allow_syncdb(self.using, obj.object.__class__): + if router.allow_migrate(self.using, obj.object.__class__): loaded_objects_in_fixture += 1 self.models.add(obj.object.__class__) try: diff --git a/django/core/management/commands/migrate.py b/django/core/management/commands/migrate.py index cf0e40e6c7..17b5a7dfe9 100644 --- a/django/core/management/commands/migrate.py +++ b/django/core/management/commands/migrate.py @@ -149,7 +149,7 @@ class Command(BaseCommand): (app.__name__.split('.')[-2], [ m for m in models.get_models(app, include_auto_created=True) - if router.allow_syncdb(connection.alias, m) + if router.allow_migrate(connection.alias, m) ]) for app in models.get_apps() if app.__name__.split('.')[-2] in apps ] diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py index 80e66b3ad4..7185644cc3 100644 --- a/django/db/backends/__init__.py +++ b/django/db/backends/__init__.py @@ -1243,7 +1243,7 @@ class BaseDatabaseIntrospection(object): for model in models.get_models(app): if not model._meta.managed: continue - if not router.allow_syncdb(self.connection.alias, model): + if not router.allow_migrate(self.connection.alias, model): continue tables.add(model._meta.db_table) tables.update([f.m2m_db_table() for f in model._meta.local_many_to_many]) @@ -1263,7 +1263,7 @@ class BaseDatabaseIntrospection(object): all_models = [] for app in models.get_apps(): for model in models.get_models(app): - if router.allow_syncdb(self.connection.alias, model): + if router.allow_migrate(self.connection.alias, model): all_models.append(model) tables = list(map(self.table_name_converter, tables)) return set([ @@ -1284,7 +1284,7 @@ class BaseDatabaseIntrospection(object): continue if model._meta.swapped: continue - if not router.allow_syncdb(self.connection.alias, model): + if not router.allow_migrate(self.connection.alias, model): continue for f in model._meta.local_fields: if isinstance(f, models.AutoField): diff --git a/django/db/utils.py b/django/db/utils.py index 36b89d9acf..c1bce7326b 100644 --- a/django/db/utils.py +++ b/django/db/utils.py @@ -262,10 +262,13 @@ class ConnectionRouter(object): return allow return obj1._state.db == obj2._state.db - def allow_syncdb(self, db, model): + def allow_migrate(self, db, model): for router in self.routers: try: - method = router.allow_syncdb + try: + method = router.allow_migrate + except AttributeError: + method = router.allow_syncdb except AttributeError: # If the router doesn't have a method, skip to the next one. pass |
