diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-10-14 09:37:45 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-10-14 11:43:15 +0200 |
| commit | 4a756cbc383bdefb683f03a0d40c0d0630ba3f60 (patch) | |
| tree | ba583ca3ac3d10a891111b15e24d58f08f92e89c /tests | |
| parent | 4a263af64e10319f70205cd7d993fc86ef3d4468 (diff) | |
[3.0.x] Fixed #30870 -- Fixed showing that RunPython operations are irreversible by migrate --plan.
Thanks Hasan Ramezani for the initial patch and Kyle Dickerson for the
report.
Backport of 06d34aab7cfb1632a1538a243db81f24498525ff from master
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/test_commands.py | 22 | ||||
| -rw-r--r-- | tests/migrations/test_migrations_plan/0005_fifth.py | 22 |
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py index f14f74b9a0..125be5de0e 100644 --- a/tests/migrations/test_commands.py +++ b/tests/migrations/test_commands.py @@ -371,6 +371,28 @@ class MigrateTests(MigrationTestBase): ' Raw SQL operation -> IRREVERSIBLE\n', out.getvalue() ) + out = io.StringIO() + call_command('migrate', 'migrations', '0005', plan=True, stdout=out, no_color=True) + # Operation is marked as irreversible only in the revert plan. + self.assertEqual( + 'Planned operations:\n' + 'migrations.0005_fifth\n' + ' Raw Python operation\n' + ' Raw Python operation\n' + ' Raw Python operation -> Feed salamander.\n', + out.getvalue() + ) + call_command('migrate', 'migrations', '0005', verbosity=0) + out = io.StringIO() + call_command('migrate', 'migrations', '0004', plan=True, stdout=out, no_color=True) + self.assertEqual( + 'Planned operations:\n' + 'migrations.0005_fifth\n' + ' Raw Python operation -> IRREVERSIBLE\n' + ' Raw Python operation -> IRREVERSIBLE\n' + ' Raw Python operation\n', + out.getvalue() + ) finally: # Cleanup by unmigrating everything: fake the irreversible, then # migrate all to zero. diff --git a/tests/migrations/test_migrations_plan/0005_fifth.py b/tests/migrations/test_migrations_plan/0005_fifth.py new file mode 100644 index 0000000000..3c569ffded --- /dev/null +++ b/tests/migrations/test_migrations_plan/0005_fifth.py @@ -0,0 +1,22 @@ +from django.db import migrations + + +def grow_tail(x, y): + pass + + +def feed(x, y): + """Feed salamander.""" + pass + + +class Migration(migrations.Migration): + dependencies = [ + ('migrations', '0004_fourth'), + ] + + operations = [ + migrations.RunPython(migrations.RunPython.noop), + migrations.RunPython(grow_tail), + migrations.RunPython(feed, migrations.RunPython.noop), + ] |
