mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[4.1.x] Fixed #33953 -- Reverted "Fixed #33201 -- Made RenameModel operation a noop for models with db_table."
Regression inafeafd6036. This revertsafeafd6036. Thanks Timothy Thomas for the report. Backport of166a3b3263from main
This commit is contained in:
committed by
Mariusz Felisiak
parent
c9ebd5b7aa
commit
7d5ccbbe1a
@@ -371,13 +371,12 @@ class RenameModel(ModelOperation):
|
||||
new_model = to_state.apps.get_model(app_label, self.new_name)
|
||||
if self.allow_migrate_model(schema_editor.connection.alias, new_model):
|
||||
old_model = from_state.apps.get_model(app_label, self.old_name)
|
||||
old_db_table = old_model._meta.db_table
|
||||
new_db_table = new_model._meta.db_table
|
||||
# Don't alter when a table name is not changed.
|
||||
if old_db_table == new_db_table:
|
||||
return
|
||||
# Move the main table
|
||||
schema_editor.alter_db_table(new_model, old_db_table, new_db_table)
|
||||
schema_editor.alter_db_table(
|
||||
new_model,
|
||||
old_model._meta.db_table,
|
||||
new_model._meta.db_table,
|
||||
)
|
||||
# Alter the fields pointing to us
|
||||
for related_object in old_model._meta.related_objects:
|
||||
if related_object.related_model == old_model:
|
||||
|
||||
Reference in New Issue
Block a user