summaryrefslogtreecommitdiff
path: root/django/db
diff options
context:
space:
mode:
authorBen Davis <bendavis78@gmail.com>2014-02-17 16:51:40 -0600
committerBen Davis <bendavis78@gmail.com>2014-02-17 16:51:40 -0600
commitdf2652c44836374bb8a691e755edbc153805f9cc (patch)
tree31058b630d615e82e70e46406d46c7b53ae30e55 /django/db
parentfaf6a911ad7357c8dd1defa3be0317a8418febf7 (diff)
Fixed #22073 - Ensure CreateTable operation handles backwards migration correctly when M2M fields are present
Diffstat (limited to 'django/db')
-rw-r--r--django/db/backends/schema.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/django/db/backends/schema.py b/django/db/backends/schema.py
index 638ae08436..bee1d0a7c2 100644
--- a/django/db/backends/schema.py
+++ b/django/db/backends/schema.py
@@ -268,6 +268,11 @@ class BaseDatabaseSchemaEditor(object):
"""
Deletes a model from the database.
"""
+ # Handle auto-created intermediary models
+ for field in model._meta.local_many_to_many:
+ if field.rel.through._meta.auto_created:
+ self.delete_model(field.rel.through)
+
# Delete the table
self.execute(self.sql_delete_table % {
"table": self.quote_name(model._meta.db_table),