summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2014-05-06 22:41:59 -0700
committerAndrew Godwin <andrew@aeracode.org>2014-05-06 22:42:53 -0700
commit2afb6e0526eeffde141d7f2b81dc54df7f45f1ba (patch)
treefc0ba74762df679fc12d217e0bf1303cdbab2642
parentf53d1576caab1594b29f6215604ef23ab6e5745e (diff)
[1.7.x] Fixed #22576: Ensure makemigrations doesn't touch the database.
-rw-r--r--django/core/management/commands/makemigrations.py7
-rw-r--r--django/db/migrations/loader.py7
2 files changed, 8 insertions, 6 deletions
diff --git a/django/core/management/commands/makemigrations.py b/django/core/management/commands/makemigrations.py
index d8aada94da..81aedb57bf 100644
--- a/django/core/management/commands/makemigrations.py
+++ b/django/core/management/commands/makemigrations.py
@@ -50,10 +50,9 @@ class Command(BaseCommand):
self.stderr.write("App '%s' could not be found. Is it in INSTALLED_APPS?" % app_label)
sys.exit(2)
- # Load the current graph state. Takes a connection, but it's not used
- # (makemigrations doesn't look at the database state).
- # Also make sure the graph is built without unmigrated apps shoehorned in.
- loader = MigrationLoader(connections[DEFAULT_DB_ALIAS])
+ # Load the current graph state. Pass in None for the connection so
+ # the loader doesn't try to resolve replaced migrations from DB.
+ loader = MigrationLoader(None)
# Before anything else, see if there's conflicting apps and drop out
# hard if there are any and they don't want to merge
diff --git a/django/db/migrations/loader.py b/django/db/migrations/loader.py
index 719f398771..0cf2c59402 100644
--- a/django/db/migrations/loader.py
+++ b/django/db/migrations/loader.py
@@ -143,8 +143,11 @@ class MigrationLoader(object):
# Load disk data
self.load_disk()
# Load database data
- recorder = MigrationRecorder(self.connection)
- self.applied_migrations = recorder.applied_migrations()
+ if self.connection is None:
+ self.applied_migrations = set()
+ else:
+ recorder = MigrationRecorder(self.connection)
+ self.applied_migrations = recorder.applied_migrations()
# Do a first pass to separate out replacing and non-replacing migrations
normal = {}
replacing = {}