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:13:27 +0200 |
| commit | 06d34aab7cfb1632a1538a243db81f24498525ff (patch) | |
| tree | 682c0cb0f41721cad61868fff3ecfc83c8e175cd /tests | |
| parent | 05186c03a30686f4898c1cb9acf4b8613035afcc (diff) | |
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.
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), + ] |
