From 1175027641f512d33909cb766563328c6b171578 Mon Sep 17 00:00:00 2001 From: Jeremy Satterfield Date: Thu, 20 Aug 2015 12:45:30 -0500 Subject: [PATCH] Fixed #25308 -- Made MigrationQuestioner respect MIGRATION_MODULES setting. --- django/db/migrations/questioner.py | 4 ++-- tests/migrations/test_commands.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/django/db/migrations/questioner.py b/django/db/migrations/questioner.py index 21ca6f2c75..a7e21969b5 100644 --- a/django/db/migrations/questioner.py +++ b/django/db/migrations/questioner.py @@ -9,7 +9,7 @@ from django.db.models.fields import NOT_PROVIDED from django.utils import datetime_safe, six, timezone from django.utils.six.moves import input -from .loader import MIGRATIONS_MODULE_NAME +from .loader import MigrationLoader class MigrationQuestioner(object): @@ -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 = "%s.%s" % (app_config.name, MIGRATIONS_MODULE_NAME) + migrations_import_path = MigrationLoader.migrations_module(app_config.label) try: migrations_module = importlib.import_module(migrations_import_path) except ImportError: diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py index 67fc57faa1..96206806ac 100644 --- a/tests/migrations/test_commands.py +++ b/tests/migrations/test_commands.py @@ -610,6 +610,16 @@ class MakeMigrationsTests(MigrationTestBase): call_command("makemigrations", "migrations", stdout=out) self.assertIn("No changes detected in app 'migrations'", out.getvalue()) + def test_makemigrations_no_apps_initial(self): + """ + makemigrations should detect initial is needed on empty migration + modules if no app provided. + """ + out = six.StringIO() + with self.temporary_migration_module(module="migrations.test_migrations_empty"): + call_command("makemigrations", stdout=out) + self.assertIn("0001_initial.py", out.getvalue()) + def test_makemigrations_migrations_announce(self): """ Makes sure that makemigrations announces the migration at the default verbosity level.