summaryrefslogtreecommitdiff
path: root/django/db
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2015-05-09 17:01:40 +0200
committerClaude Paroz <claude@2xlibre.net>2015-05-13 18:30:36 +0200
commitf61c4f490dc4c8ec6ba94ad4f40247db2425fc3e (patch)
tree8ce61422333b0b4fb850a13b1f776f0024bd0d1d /django/db
parent3c8fe5dddf34533a419d2deed5208a28de32cb4a (diff)
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.
Diffstat (limited to 'django/db')
-rw-r--r--django/db/migrations/exceptions.py5
-rw-r--r--django/db/migrations/recorder.py10
2 files changed, 13 insertions, 2 deletions
diff --git a/django/db/migrations/exceptions.py b/django/db/migrations/exceptions.py
index d8b386e1ac..8b60a035fe 100644
--- a/django/db/migrations/exceptions.py
+++ b/django/db/migrations/exceptions.py
@@ -1,5 +1,6 @@
from __future__ import unicode_literals
+from django.db.utils import DatabaseError
from django.utils.encoding import python_2_unicode_compatible
@@ -53,3 +54,7 @@ class NodeNotFoundError(LookupError):
def __repr__(self):
return "NodeNotFoundError(%r)" % self.node
+
+
+class MigrationSchemaMissing(DatabaseError):
+ pass
diff --git a/django/db/migrations/recorder.py b/django/db/migrations/recorder.py
index d1071cecb7..2dcbe6c042 100644
--- a/django/db/migrations/recorder.py
+++ b/django/db/migrations/recorder.py
@@ -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):
"""