MCPcopy
hub / github.com/django/django / delete_tables

Method delete_tables

tests/schema/tests.py:164–179  ·  view source on GitHub ↗

Deletes all model tables for our models for a clean test environment

(self)

Source from the content-addressed store, hash-verified

162 editor.delete_model(model)
163
164 def delete_tables(self):
165 "Deletes all model tables for our models for a clean test environment"
166 converter = connection.introspection.identifier_converter
167 with connection.schema_editor() as editor:
168 connection.disable_constraint_checking()
169 table_names = connection.introspection.table_names()
170 if connection.features.ignores_table_name_case:
171 table_names = [table_name.lower() for table_name in table_names]
172 for model in itertools.chain(SchemaTests.models, self.local_models):
173 tbl = converter(model._meta.db_table)
174 if connection.features.ignores_table_name_case:
175 tbl = tbl.lower()
176 if tbl in table_names:
177 editor.delete_model(model)
178 table_names.remove(tbl)
179 connection.enable_constraint_checking()
180
181 def column_classes(self, model):
182 with connection.cursor() as cursor:

Callers 1

tearDownMethod · 0.95

Calls 7

schema_editorMethod · 0.80
table_namesMethod · 0.80
chainMethod · 0.45
delete_modelMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected