1
0
mirror of https://github.com/django/django.git synced 2025-10-28 08:06:09 +00:00

Fixed #24742 -- Made runserver.check_migrations ignore read-only databases

Thanks Luis Del Giudice for the report, and Aymeric Augustin and Markus
Holtermann for the reviews.
This commit is contained in:
Claude Paroz
2015-05-09 17:01:40 +02:00
parent 3c8fe5dddf
commit f61c4f490d
4 changed files with 51 additions and 8 deletions

View File

@@ -2,9 +2,12 @@ from __future__ import unicode_literals
from django.apps.registry import Apps
from django.db import models
from django.db.utils import DatabaseError
from django.utils.encoding import python_2_unicode_compatible
from django.utils.timezone import now
from .exceptions import MigrationSchemaMissing
class MigrationRecorder(object):
"""
@@ -49,8 +52,11 @@ class MigrationRecorder(object):
if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
return
# Make the table
with self.connection.schema_editor() as editor:
editor.create_model(self.Migration)
try:
with self.connection.schema_editor() as editor:
editor.create_model(self.Migration)
except DatabaseError as exc:
raise MigrationSchemaMissing("Unable to create the django_migrations table (%s)" % exc)
def applied_migrations(self):
"""