Fixed #22248 -- Made RenameModel reversible
This commit is contained in:
parent
5617508fb9
commit
cf7a2a000e
|
@ -106,8 +106,6 @@ class RenameModel(Operation):
|
||||||
Renames a model.
|
Renames a model.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
reversible = False
|
|
||||||
|
|
||||||
def __init__(self, old_name, new_name):
|
def __init__(self, old_name, new_name):
|
||||||
self.old_name = old_name
|
self.old_name = old_name
|
||||||
self.new_name = new_name
|
self.new_name = new_name
|
||||||
|
|
|
@ -65,3 +65,6 @@ Bugfixes
|
||||||
|
|
||||||
* Fixed :djadmin:`squashmigrations` to respect the ``--no-optimize`` parameter
|
* Fixed :djadmin:`squashmigrations` to respect the ``--no-optimize`` parameter
|
||||||
(:ticket:`23799`).
|
(:ticket:`23799`).
|
||||||
|
|
||||||
|
* Made :class:`~django.db.migrations.operations.RenameModel` reversible
|
||||||
|
(:ticket:`22248`)
|
||||||
|
|
|
@ -434,8 +434,7 @@ class OperationTests(OperationTestBase):
|
||||||
self.assertFKNotExists("test_rnmo_rider", ["pony_id"], ("test_rnmo_pony", "id"))
|
self.assertFKNotExists("test_rnmo_rider", ["pony_id"], ("test_rnmo_pony", "id"))
|
||||||
self.assertFKExists("test_rnmo_rider", ["pony_id"], ("test_rnmo_horse", "id"))
|
self.assertFKExists("test_rnmo_rider", ["pony_id"], ("test_rnmo_horse", "id"))
|
||||||
# And test reversal
|
# And test reversal
|
||||||
with connection.schema_editor() as editor:
|
self.unapply_operations("test_rnmo", project_state, [operation])
|
||||||
operation.database_backwards("test_rnmo", editor, new_state, project_state)
|
|
||||||
self.assertTableExists("test_rnmo_pony")
|
self.assertTableExists("test_rnmo_pony")
|
||||||
self.assertTableNotExists("test_rnmo_horse")
|
self.assertTableNotExists("test_rnmo_horse")
|
||||||
if connection.features.supports_foreign_keys:
|
if connection.features.supports_foreign_keys:
|
||||||
|
|
Loading…
Reference in New Issue