Updated the mechanism to disable iteration trough all migrations when setting up test databases.

- Legacy-Id: 14671
This commit is contained in:
Henrik Levkowetz 2018-02-22 00:10:39 +00:00
parent e859a556f7
commit c3fb6450f7
2 changed files with 3 additions and 17 deletions

View file

@ -11,20 +11,13 @@ from settings import * # pyflakes:ignore
# the test database instead of doing it through the migrations. Taken from
# https://gist.github.com/NotSqrt/5f3c76cd15e40ef62d09
## To be removed after upgrade to Django 1.8 ##
class DisableMigrations(object):
def __contains__(self, item):
return True
def __getitem__(self, item):
# The string below is significant. It has to include the value of
# django.db.migrations.loader.MIGRATIONS_MODULE_NAME. Used by django
# 1.7 code in django.db.migrations.loader.MigrationLoader to
# determine whether or not to run migrations for a given module
from django.db.migrations.loader import MIGRATIONS_MODULE_NAME
return "no " + MIGRATIONS_MODULE_NAME
return None
MIGRATION_MODULES = DisableMigrations()

View file

@ -15,24 +15,17 @@ debug.debug = True
# the test database instead of doing it through the migrations. Taken from
# https://gist.github.com/NotSqrt/5f3c76cd15e40ef62d09
## To be removed after upgrade to Django 1.8 ##
class DisableMigrations(object):
def __contains__(self, item):
return True
def __getitem__(self, item):
from django.db.migrations.loader import MIGRATIONS_MODULE_NAME
# The string below is significant. It has to include the value of
# django.db.migrations.loader.MIGRATIONS_MODULE_NAME. Used by django
# 1.7 code in django.db.migrations.loader.MigrationLoader to
# determine whether or not to run migrations for a given module.
# By returning a non-existent path, we ignore migrations.
return "no_" + MIGRATIONS_MODULE_NAME
return None
MIGRATION_MODULES = DisableMigrations()
DATABASES = {
'default': {
'NAME': 'test.db',