From 7d728566e4b8b5528f9ca3678ec9b72ca4b3801f Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Wed, 3 Jul 2019 09:28:57 +0200 Subject: [PATCH 2/2] do not use public schema for finding list of migrations (#31042) --- .../multitenant/management/commands/migrate_schemas.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/hobo/multitenant/management/commands/migrate_schemas.py b/hobo/multitenant/management/commands/migrate_schemas.py index 579c1d8..87e28b5 100644 --- a/hobo/multitenant/management/commands/migrate_schemas.py +++ b/hobo/multitenant/management/commands/migrate_schemas.py @@ -58,13 +58,9 @@ class MigrateSchemasCommand(SyncCommon): for app in apps.get_app_configs(): if app.name in settings.TENANT_APPS: app_labels.append(app.label) - loader = MigrationLoader(connection) + loader = MigrationLoader(None) loader.load_disk() - recorder = MigrationRecorder(connection) - applied_public_migrations = set( - [(app, migration) - for app, migration in recorder.applied_migrations() - if app in app_labels and (app, migration) in loader.disk_migrations]) + all_migrations = set([(app, migration) for app, migration in loader.disk_migrations if app in app_labels]) for tenant in TenantMiddleware.get_tenants(): connection.set_schema(tenant.schema_name, include_public=False) applied_migrations = self.get_applied_migrations(app_labels) @@ -72,7 +68,7 @@ class MigrateSchemasCommand(SyncCommon): # never skip migrations if explicit migration actions # are given. applied_migrations = [] - if all([x in applied_migrations for x in applied_public_migrations]): + if all([x in applied_migrations for x in all_migrations]): if int(self.options.get('verbosity', 1)) >= 1: self._notice("=== Skipping migrations of schema %s" % tenant.schema_name) continue -- 2.20.1