summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2023-05-17 13:14:43 +0200
committerGitHub <noreply@github.com>2023-05-17 13:14:43 +0200
commitc52f4295f254e1c14af769d22b1a5f516a941f58 (patch)
tree8770afde4c44cb372b24d468f33d61ecab5c387e /tests
parent93830abf7694e0f281931f10eeaa34993855e7dd (diff)
downloaddjango-c52f4295f254e1c14af769d22b1a5f516a941f58.tar.gz
Fixed #34568 -- Made makemigrations --update respect --name option.
Thanks David Sanders for the report.
Diffstat (limited to 'tests')
-rw-r--r--tests/migrations/test_commands.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py
index b1c91bcf5c..387cef924a 100644
--- a/tests/migrations/test_commands.py
+++ b/tests/migrations/test_commands.py
@@ -2655,6 +2655,32 @@ class MakeMigrationsTests(MigrationTestBase):
self.assertNotEqual(initial_content, fp.read())
self.assertIn(f"Deleted {migration_file}", out.getvalue())
+ def test_makemigrations_update_custom_name(self):
+ custom_name = "delete_something"
+ with self.temporary_migration_module(
+ module="migrations.test_migrations"
+ ) as migration_dir:
+ old_migration_file = os.path.join(migration_dir, "0002_second.py")
+ with open(old_migration_file) as fp:
+ initial_content = fp.read()
+
+ with captured_stdout() as out:
+ call_command(
+ "makemigrations", "migrations", update=True, name=custom_name
+ )
+ self.assertFalse(
+ any(
+ filename.startswith("0003")
+ for filename in os.listdir(migration_dir)
+ )
+ )
+ self.assertIs(os.path.exists(old_migration_file), False)
+ new_migration_file = os.path.join(migration_dir, f"0002_{custom_name}.py")
+ self.assertIs(os.path.exists(new_migration_file), True)
+ with open(new_migration_file) as fp:
+ self.assertNotEqual(initial_content, fp.read())
+ self.assertIn(f"Deleted {old_migration_file}", out.getvalue())
+
def test_makemigrations_update_applied_migration(self):
recorder = MigrationRecorder(connection)
recorder.record_applied("migrations", "0001_initial")