mirror of https://github.com/django/django.git
Isolated migrations.test_commands.MigrateTests.test_migrate_plan.
This commit is contained in:
parent
2839659b42
commit
05186c03a3
|
@ -327,53 +327,55 @@ class MigrateTests(MigrationTestBase):
|
||||||
" Raw SQL operation -> ['SELECT * FROM migrations_author']\n",
|
" Raw SQL operation -> ['SELECT * FROM migrations_author']\n",
|
||||||
out.getvalue()
|
out.getvalue()
|
||||||
)
|
)
|
||||||
# Migrate to the third migration.
|
try:
|
||||||
call_command('migrate', 'migrations', '0003', verbosity=0)
|
# Migrate to the third migration.
|
||||||
out = io.StringIO()
|
call_command('migrate', 'migrations', '0003', verbosity=0)
|
||||||
# Show the plan for when there is nothing to apply.
|
out = io.StringIO()
|
||||||
call_command('migrate', 'migrations', '0003', plan=True, stdout=out, no_color=True)
|
# Show the plan for when there is nothing to apply.
|
||||||
self.assertEqual(
|
call_command('migrate', 'migrations', '0003', plan=True, stdout=out, no_color=True)
|
||||||
'Planned operations:\n'
|
self.assertEqual(
|
||||||
' No planned migration operations.\n',
|
'Planned operations:\n'
|
||||||
out.getvalue()
|
' No planned migration operations.\n',
|
||||||
)
|
out.getvalue()
|
||||||
out = io.StringIO()
|
)
|
||||||
# Show the plan for reverse migration back to 0001.
|
out = io.StringIO()
|
||||||
call_command('migrate', 'migrations', '0001', plan=True, stdout=out, no_color=True)
|
# Show the plan for reverse migration back to 0001.
|
||||||
self.assertEqual(
|
call_command('migrate', 'migrations', '0001', plan=True, stdout=out, no_color=True)
|
||||||
'Planned operations:\n'
|
self.assertEqual(
|
||||||
'migrations.0003_third\n'
|
'Planned operations:\n'
|
||||||
' Undo Create model Author\n'
|
'migrations.0003_third\n'
|
||||||
" Raw SQL operation -> ['SELECT * FROM migrations_book']\n"
|
' Undo Create model Author\n'
|
||||||
'migrations.0002_second\n'
|
" Raw SQL operation -> ['SELECT * FROM migrations_book']\n"
|
||||||
' Undo Create model Book\n'
|
'migrations.0002_second\n'
|
||||||
" Raw SQL operation -> ['SELECT * FROM migrations_salamand…\n",
|
' Undo Create model Book\n'
|
||||||
out.getvalue()
|
" Raw SQL operation -> ['SELECT * FROM migrations_salamand…\n",
|
||||||
)
|
out.getvalue()
|
||||||
out = io.StringIO()
|
)
|
||||||
# Show the migration plan to fourth, with truncated details.
|
out = io.StringIO()
|
||||||
call_command('migrate', 'migrations', '0004', plan=True, stdout=out, no_color=True)
|
# Show the migration plan to fourth, with truncated details.
|
||||||
self.assertEqual(
|
call_command('migrate', 'migrations', '0004', plan=True, stdout=out, no_color=True)
|
||||||
'Planned operations:\n'
|
self.assertEqual(
|
||||||
'migrations.0004_fourth\n'
|
'Planned operations:\n'
|
||||||
' Raw SQL operation -> SELECT * FROM migrations_author WHE…\n',
|
'migrations.0004_fourth\n'
|
||||||
out.getvalue()
|
' Raw SQL operation -> SELECT * FROM migrations_author WHE…\n',
|
||||||
)
|
out.getvalue()
|
||||||
# Show the plan when an operation is irreversible.
|
)
|
||||||
# Migrate to the fourth migration.
|
# Show the plan when an operation is irreversible.
|
||||||
call_command('migrate', 'migrations', '0004', verbosity=0)
|
# Migrate to the fourth migration.
|
||||||
out = io.StringIO()
|
call_command('migrate', 'migrations', '0004', verbosity=0)
|
||||||
call_command('migrate', 'migrations', '0003', plan=True, stdout=out, no_color=True)
|
out = io.StringIO()
|
||||||
self.assertEqual(
|
call_command('migrate', 'migrations', '0003', plan=True, stdout=out, no_color=True)
|
||||||
'Planned operations:\n'
|
self.assertEqual(
|
||||||
'migrations.0004_fourth\n'
|
'Planned operations:\n'
|
||||||
' Raw SQL operation -> IRREVERSIBLE\n',
|
'migrations.0004_fourth\n'
|
||||||
out.getvalue()
|
' Raw SQL operation -> IRREVERSIBLE\n',
|
||||||
)
|
out.getvalue()
|
||||||
# Cleanup by unmigrating everything: fake the irreversible, then
|
)
|
||||||
# migrate all to zero.
|
finally:
|
||||||
call_command('migrate', 'migrations', '0003', fake=True, verbosity=0)
|
# Cleanup by unmigrating everything: fake the irreversible, then
|
||||||
call_command('migrate', 'migrations', 'zero', verbosity=0)
|
# migrate all to zero.
|
||||||
|
call_command('migrate', 'migrations', '0003', fake=True, verbosity=0)
|
||||||
|
call_command('migrate', 'migrations', 'zero', verbosity=0)
|
||||||
|
|
||||||
@override_settings(MIGRATION_MODULES={'migrations': 'migrations.test_migrations_empty'})
|
@override_settings(MIGRATION_MODULES={'migrations': 'migrations.test_migrations_empty'})
|
||||||
def test_showmigrations_no_migrations(self):
|
def test_showmigrations_no_migrations(self):
|
||||||
|
|
Loading…
Reference in New Issue