|
@@ -789,6 +789,24 @@ class SchemaTests(TransactionTestCase):
|
|
|
|
|
|
self.assertEqual(columns["bits"][0], "TextField")
|
|
|
|
|
|
+ def test_remove_field(self):
|
|
|
+ with connection.schema_editor() as editor:
|
|
|
+ editor.create_model(Author)
|
|
|
+ with CaptureQueriesContext(connection) as ctx:
|
|
|
+ editor.remove_field(Author, Author._meta.get_field("name"))
|
|
|
+ columns = self.column_classes(Author)
|
|
|
+ self.assertNotIn("name", columns)
|
|
|
+ if getattr(connection.features, "can_alter_table_drop_column", True):
|
|
|
+
|
|
|
+ self.assertIs(
|
|
|
+ any("CREATE TABLE" in query["sql"] for query in ctx.captured_queries),
|
|
|
+ False,
|
|
|
+ )
|
|
|
+ self.assertIs(
|
|
|
+ any("DROP TABLE" in query["sql"] for query in ctx.captured_queries),
|
|
|
+ False,
|
|
|
+ )
|
|
|
+
|
|
|
def test_alter(self):
|
|
|
"""
|
|
|
Tests simple altering of fields
|