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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user