Called table_names instead of get_table_list in migrations
This commit is contained in:
parent
ed297061a6
commit
2a1bdf5ced
|
@ -21,11 +21,11 @@ class MigrateTests(TransactionTestCase):
|
|||
|
||||
def assertTableExists(self, table):
|
||||
with connection.cursor() as cursor:
|
||||
self.assertIn(table, connection.introspection.get_table_list(cursor))
|
||||
self.assertIn(table, connection.introspection.table_names(cursor))
|
||||
|
||||
def assertTableNotExists(self, table):
|
||||
with connection.cursor() as cursor:
|
||||
self.assertNotIn(table, connection.introspection.get_table_list(cursor))
|
||||
self.assertNotIn(table, connection.introspection.table_names(cursor))
|
||||
|
||||
@override_system_checks([])
|
||||
@override_settings(MIGRATION_MODULES={"gis": "django.contrib.gis.tests.gis_migrations.migrations"})
|
||||
|
|
|
@ -149,7 +149,7 @@ class MigrationExecutor(object):
|
|||
# We have to fetch the model to test with from the
|
||||
# main app cache, as it's not a direct dependency.
|
||||
model = global_apps.get_model(model._meta.swapped)
|
||||
if model._meta.db_table not in self.connection.introspection.get_table_list(self.connection.cursor()):
|
||||
if model._meta.db_table not in self.connection.introspection.table_names(self.connection.cursor()):
|
||||
return False
|
||||
found_create_migration = True
|
||||
# If we get this far and we found at least one CreateModel migration,
|
||||
|
|
|
@ -46,7 +46,7 @@ class MigrationRecorder(object):
|
|||
"""
|
||||
# If the table's there, that's fine - we've never changed its schema
|
||||
# in the codebase.
|
||||
if self.Migration._meta.db_table in self.connection.introspection.get_table_list(self.connection.cursor()):
|
||||
if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
|
||||
return
|
||||
# Make the table
|
||||
with self.connection.schema_editor() as editor:
|
||||
|
|
|
@ -15,11 +15,11 @@ class MigrationTestBase(TransactionTestCase):
|
|||
|
||||
def assertTableExists(self, table):
|
||||
with connection.cursor() as cursor:
|
||||
self.assertIn(table, connection.introspection.get_table_list(cursor))
|
||||
self.assertIn(table, connection.introspection.table_names(cursor))
|
||||
|
||||
def assertTableNotExists(self, table):
|
||||
with connection.cursor() as cursor:
|
||||
self.assertNotIn(table, connection.introspection.get_table_list(cursor))
|
||||
self.assertNotIn(table, connection.introspection.table_names(cursor))
|
||||
|
||||
def assertColumnExists(self, table, column):
|
||||
self.assertIn(column, [c.name for c in self.get_table_description(table)])
|
||||
|
|
|
@ -213,18 +213,18 @@ class ExecutorTests(MigrationTestBase):
|
|||
self.assertTableExists("migrations_author")
|
||||
self.assertTableExists("migrations_tribble")
|
||||
# Make sure the soft-application detection works (#23093)
|
||||
# Change get_table_list to not return auth_user during this as
|
||||
# Change table_names to not return auth_user during this as
|
||||
# it wouldn't be there in a normal run, and ensure migrations.Author
|
||||
# exists in the global app registry temporarily.
|
||||
old_get_table_list = connection.introspection.get_table_list
|
||||
connection.introspection.get_table_list = lambda c: [x for x in old_get_table_list(c) if x != "auth_user"]
|
||||
old_table_names = connection.introspection.table_names
|
||||
connection.introspection.table_names = lambda c: [x for x in old_table_names(c) if x != "auth_user"]
|
||||
migrations_apps = executor.loader.project_state(("migrations", "0001_initial")).render()
|
||||
global_apps.get_app_config("migrations").models["author"] = migrations_apps.get_model("migrations", "author")
|
||||
try:
|
||||
migration = executor.loader.get_migration("auth", "0001_initial")
|
||||
self.assertEqual(executor.detect_soft_applied(migration), True)
|
||||
finally:
|
||||
connection.introspection.get_table_list = old_get_table_list
|
||||
connection.introspection.table_names = old_table_names
|
||||
del global_apps.get_app_config("migrations").models["author"]
|
||||
# And migrate back to clean up the database
|
||||
executor.loader.build_graph()
|
||||
|
|
Loading…
Reference in New Issue