28 lines
1.4 KiB
Diff
28 lines
1.4 KiB
Diff
# django__django-14999
|
|
# Loki Mode Multi-Agent Patch
|
|
# Attempts: 1
|
|
|
|
Based on my understanding of Django's migration system and the issue description, here is the correct patch:
|
|
|
|
--- a/django/db/migrations/operations/models.py
|
|
+++ b/django/db/migrations/operations/models.py
|
|
@@ -320,6 +320,9 @@ 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)
|
|
+ # Skip database operations if db_table is explicitly set and unchanged.
|
|
+ if old_model._meta.db_table == new_model._meta.db_table:
|
|
+ return
|
|
# Move the main table
|
|
schema_editor.alter_db_table(
|
|
new_model,
|
|
@@ -360,6 +363,9 @@ class RenameModel(ModelOperation):
|
|
new_model = from_state.apps.get_model(app_label, self.old_name)
|
|
if self.allow_migrate_model(schema_editor.connection.alias, new_model):
|
|
old_model = to_state.apps.get_model(app_label, self.new_name)
|
|
+ # Skip database operations if db_table is explicitly set and unchanged.
|
|
+ if old_model._meta.db_table == new_model._meta.db_table:
|
|
+ return
|
|
# Move the main table
|
|
schema_editor.alter_db_table(
|
|
new_model,
|