From 5c56ce7a3f7568745225b190c5fce6b3442d5cdb Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Thu, 14 Jul 2016 09:10:15 -0400 Subject: [PATCH] [1.10.x] Reverted "Fixed #25388 -- Added an option to allow disabling of migrations during test database creation" This reverts commit 157d7f1f1de4705daddebb77f21bd7097a74513d since it disables migrations all the time, not just during tests. Backport of 944e66cb1db6614ef0644b9030dd1d75e950767c from master --- django/db/migrations/loader.py | 6 ++---- django/db/migrations/questioner.py | 2 +- django/db/migrations/writer.py | 2 +- docs/ref/settings.txt | 11 ----------- docs/releases/1.10.txt | 3 --- tests/migrations/test_loader.py | 19 +------------------ 6 files changed, 5 insertions(+), 38 deletions(-) diff --git a/django/db/migrations/loader.py b/django/db/migrations/loader.py index 094ac1dd80..a5b7cce393 100644 --- a/django/db/migrations/loader.py +++ b/django/db/migrations/loader.py @@ -51,10 +51,8 @@ class MigrationLoader(object): if load: self.build_graph() - def migrations_module(self, app_label): - if (self.connection is not None and - not self.connection.settings_dict.get('TEST', {}).get('MIGRATE', True)): - return None + @classmethod + def migrations_module(cls, app_label): if app_label in settings.MIGRATION_MODULES: return settings.MIGRATION_MODULES[app_label] else: diff --git a/django/db/migrations/questioner.py b/django/db/migrations/questioner.py index 36144f1a55..593e0ace3b 100644 --- a/django/db/migrations/questioner.py +++ b/django/db/migrations/questioner.py @@ -37,7 +37,7 @@ class MigrationQuestioner(object): app_config = apps.get_app_config(app_label) except LookupError: # It's a fake app. return self.defaults.get("ask_initial", False) - migrations_import_path = MigrationLoader(None, load=False).migrations_module(app_config.label) + migrations_import_path = MigrationLoader.migrations_module(app_config.label) if migrations_import_path is None: # It's an application with migrations disabled. return self.defaults.get("ask_initial", False) diff --git a/django/db/migrations/writer.py b/django/db/migrations/writer.py index 7da51516b9..137f83dbc0 100644 --- a/django/db/migrations/writer.py +++ b/django/db/migrations/writer.py @@ -221,7 +221,7 @@ class MigrationWriter(object): @property def basedir(self): - migrations_package_name = MigrationLoader(None, load=False).migrations_module(self.migration.app_label) + migrations_package_name = MigrationLoader.migrations_module(self.migration.app_label) if migrations_package_name is None: raise ValueError( diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt index b7ba1f6b5e..3cb6b0408e 100644 --- a/docs/ref/settings.txt +++ b/docs/ref/settings.txt @@ -709,17 +709,6 @@ The creation-order dependencies of the database. See the documentation on :ref:`controlling the creation order of test databases ` for details. -.. setting:: TEST_MIGRATE - -``MIGRATE`` -^^^^^^^^^^^ - -.. versionadded:: 1.10 - -Default: ``True`` - -If set to ``False``, Django won't use migrations to create the test database. - .. setting:: TEST_MIRROR ``MIRROR`` diff --git a/docs/releases/1.10.txt b/docs/releases/1.10.txt index a955e351e2..30a919de88 100644 --- a/docs/releases/1.10.txt +++ b/docs/releases/1.10.txt @@ -480,9 +480,6 @@ Tests and run selectively with the new :option:`test --tag` and :option:`test --exclude-tag` options. -* Added the :setting:`DATABASES['TEST']['MIGRATE'] ` option to - allow disabling of migrations during test database creation. - * You can now login and use sessions with the test client even if :mod:`django.contrib.sessions` is not in :setting:`INSTALLED_APPS`. diff --git a/tests/migrations/test_loader.py b/tests/migrations/test_loader.py index bf948768fd..0b014f7d57 100644 --- a/tests/migrations/test_loader.py +++ b/tests/migrations/test_loader.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals from unittest import skipIf -from django.db import ConnectionHandler, connection, connections +from django.db import connection, connections from django.db.migrations.exceptions import ( AmbiguityError, InconsistentMigrationHistory, NodeNotFoundError, ) @@ -204,23 +204,6 @@ class LoaderTests(TestCase): self.assertEqual(migration_loader.migrated_apps, set()) self.assertEqual(migration_loader.unmigrated_apps, {'migrated_app'}) - @override_settings( - INSTALLED_APPS=['migrations.migrations_test_apps.migrated_app'], - ) - def test_disable_migrations(self): - connections = ConnectionHandler({ - 'default': { - 'NAME': ':memory:', - 'ENGINE': 'django.db.backends.sqlite3', - 'TEST': { - 'MIGRATE': False, - }, - }, - }) - migration_loader = MigrationLoader(connections['default']) - self.assertEqual(migration_loader.migrated_apps, set()) - self.assertEqual(migration_loader.unmigrated_apps, {'migrated_app'}) - @override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations_squashed"}) def test_loading_squashed(self): "Tests loading a squashed migration"