1
0
mirror of https://github.com/django/django.git synced 2025-10-27 07:36:08 +00:00

[1.10.x] Fixed #27054 -- Fixed makemigrations crash with a read-only database.

Backport of 76ab885118 from master
This commit is contained in:
Jim Nicholls
2016-08-13 19:33:58 +10:00
committed by Tim Graham
parent c24a47b3e6
commit 16f032e69f
4 changed files with 45 additions and 4 deletions

View File

@@ -4,11 +4,12 @@ from unittest import skipIf
from django.db import connection, connections
from django.db.migrations.exceptions import (
AmbiguityError, InconsistentMigrationHistory, NodeNotFoundError,
AmbiguityError, InconsistentMigrationHistory, MigrationSchemaMissing,
NodeNotFoundError,
)
from django.db.migrations.loader import MigrationLoader
from django.db.migrations.recorder import MigrationRecorder
from django.test import TestCase, modify_settings, override_settings
from django.test import TestCase, mock, modify_settings, override_settings
from django.utils import six
@@ -464,3 +465,12 @@ class LoaderTests(TestCase):
('app1', '4_auto'),
}
self.assertEqual(plan, expected_plan)
def test_readonly_database(self):
"""
check_consistent_history() ignores read-only databases, possibly
without a django_migrations table.
"""
with mock.patch.object(MigrationRecorder, 'ensure_schema', side_effect=MigrationSchemaMissing()):
loader = MigrationLoader(connection=None)
loader.check_consistent_history(connection)