mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #31402 -- Added migrate --check option.
Command exits with non-zero status if unapplied migrations exist.
This commit is contained in:
parent
4216225480
commit
d0da2820ca
4 changed files with 53 additions and 0 deletions
|
@ -249,6 +249,39 @@ class MigrateTests(MigrationTestBase):
|
|||
with self.assertRaisesMessage(CommandError, "Conflicting migrations detected"):
|
||||
call_command("migrate", "migrations")
|
||||
|
||||
@override_settings(MIGRATION_MODULES={
|
||||
'migrations': 'migrations.test_migrations',
|
||||
})
|
||||
def test_migrate_check(self):
|
||||
with self.assertRaises(SystemExit):
|
||||
call_command('migrate', 'migrations', '0001', check_unapplied=True, verbosity=0)
|
||||
self.assertTableNotExists('migrations_author')
|
||||
self.assertTableNotExists('migrations_tribble')
|
||||
self.assertTableNotExists('migrations_book')
|
||||
|
||||
@override_settings(MIGRATION_MODULES={
|
||||
'migrations': 'migrations.test_migrations_plan',
|
||||
})
|
||||
def test_migrate_check_plan(self):
|
||||
out = io.StringIO()
|
||||
with self.assertRaises(SystemExit):
|
||||
call_command(
|
||||
'migrate',
|
||||
'migrations',
|
||||
'0001',
|
||||
check_unapplied=True,
|
||||
plan=True,
|
||||
stdout=out,
|
||||
no_color=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
'Planned operations:\n'
|
||||
'migrations.0001_initial\n'
|
||||
' Create model Salamander\n'
|
||||
' Raw Python operation -> Grow salamander tail.\n',
|
||||
out.getvalue(),
|
||||
)
|
||||
|
||||
@override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"})
|
||||
def test_showmigrations_list(self):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue