diff options
| author | Tim Graham <timograham@gmail.com> | 2014-10-22 09:59:00 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-10-23 08:05:39 -0400 |
| commit | 41b337efa085b6b9cfdb2cf724d977005ff77e75 (patch) | |
| tree | 5cea3351c57499979f018d5e35441d2146a74931 /django/db | |
| parent | 22c85bf1a8e938def99bf76afc11486655ff3e11 (diff) | |
Fixed #23630 -- Made AlterModelTable rename auto-created M2M tables.
Thanks Naddiseo for the report, Andrew Godwin for guidance,
and Shai Berger for review.
Diffstat (limited to 'django/db')
| -rw-r--r-- | django/db/migrations/operations/models.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/django/db/migrations/operations/models.py b/django/db/migrations/operations/models.py index eade3ee878..0e4a1a50f5 100644 --- a/django/db/migrations/operations/models.py +++ b/django/db/migrations/operations/models.py @@ -212,6 +212,14 @@ class AlterModelTable(Operation): old_model._meta.db_table, new_model._meta.db_table, ) + # Rename M2M fields whose name is based on this model's db_table + for (old_field, new_field) in zip(old_model._meta.local_many_to_many, new_model._meta.local_many_to_many): + if new_field.rel.through._meta.auto_created: + schema_editor.alter_db_table( + new_field.rel.through, + old_field.rel.through._meta.db_table, + new_field.rel.through._meta.db_table, + ) def database_backwards(self, app_label, schema_editor, from_state, to_state): return self.database_forwards(app_label, schema_editor, from_state, to_state) |
