summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChinmoy Chakraborty <chinmoy12c@gmail.com>2020-06-05 21:32:21 +0530
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-06-12 10:26:06 +0200
commit2928019e0ccd8e9c7d3a3fba7722a7af87018e5d (patch)
tree341b4bbd1c72440441b686633dbda8091753e268 /tests
parentaeb8996a6706cad3e96d8221760c1cb408ee7ed9 (diff)
Fixed #31645 -- Enhanced the migration warning for migrate commmand.
Added the list of apps with changes not reflected in migrations.
Diffstat (limited to 'tests')
-rw-r--r--tests/migrations/test_commands.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py
index f7b21931e4..78cada9106 100644
--- a/tests/migrations/test_commands.py
+++ b/tests/migrations/test_commands.py
@@ -890,6 +890,40 @@ class MigrateTests(MigrationTestBase):
applied_migrations = recorder.applied_migrations()
self.assertNotIn(("migrations", "0001_initial"), applied_migrations)
+ @override_settings(INSTALLED_APPS=[
+ 'migrations.migrations_test_apps.migrated_unapplied_app',
+ 'migrations.migrations_test_apps.migrated_app',
+ ])
+ def test_migrate_not_reflected_changes(self):
+ class NewModel1(models.Model):
+ class Meta():
+ app_label = 'migrated_app'
+
+ class NewModel2(models.Model):
+ class Meta():
+ app_label = 'migrated_unapplied_app'
+
+ out = io.StringIO()
+ try:
+ call_command('migrate', verbosity=0)
+ call_command('migrate', stdout=out, no_color=True)
+ self.assertEqual(
+ "operations to perform:\n"
+ " apply all migrations: migrated_app, migrated_unapplied_app\n"
+ "running migrations:\n"
+ " no migrations to apply.\n"
+ " your models in app(s): 'migrated_app', "
+ "'migrated_unapplied_app' have changes that are not yet "
+ "reflected in a migration, and so won't be applied.\n"
+ " run 'manage.py makemigrations' to make new migrations, and "
+ "then re-run 'manage.py migrate' to apply them.\n",
+ out.getvalue().lower(),
+ )
+ finally:
+ # Unmigrate everything.
+ call_command('migrate', 'migrated_app', 'zero', verbosity=0)
+ call_command('migrate', 'migrated_unapplied_app', 'zero', verbosity=0)
+
class MakeMigrationsTests(MigrationTestBase):
"""