Refs #24919 -- Raised more helpful error message for disabled migrations
This commit is contained in:
parent
a3c01b0dd8
commit
f45ee19746
|
@ -241,6 +241,13 @@ class MigrationWriter(object):
|
||||||
def basedir(self):
|
def basedir(self):
|
||||||
migrations_package_name = MigrationLoader.migrations_module(self.migration.app_label)
|
migrations_package_name = MigrationLoader.migrations_module(self.migration.app_label)
|
||||||
|
|
||||||
|
if migrations_package_name is None:
|
||||||
|
raise ValueError(
|
||||||
|
"Django can't create migrations for app '%s' because "
|
||||||
|
"migrations have been disabled via the MIGRATION_MODULES "
|
||||||
|
"setting." % self.migration.app_label
|
||||||
|
)
|
||||||
|
|
||||||
# See if we can import the migrations module directly
|
# See if we can import the migrations module directly
|
||||||
try:
|
try:
|
||||||
migrations_module = import_module(migrations_package_name)
|
migrations_module = import_module(migrations_package_name)
|
||||||
|
|
|
@ -593,6 +593,19 @@ class MakeMigrationsTests(MigrationTestBase):
|
||||||
self.assertIn('dependencies=[\n]', content)
|
self.assertIn('dependencies=[\n]', content)
|
||||||
self.assertIn('operations=[\n]', content)
|
self.assertIn('operations=[\n]', content)
|
||||||
|
|
||||||
|
@override_settings(MIGRATION_MODULES={"migrations": None})
|
||||||
|
def test_makemigrations_disabled_migrations_for_app(self):
|
||||||
|
"""
|
||||||
|
makemigrations raises a nice error when migrations are disabled for an
|
||||||
|
app.
|
||||||
|
"""
|
||||||
|
msg = (
|
||||||
|
"Django can't create migrations for app 'migrations' because migrations "
|
||||||
|
"have been disabled via the MIGRATION_MODULES setting."
|
||||||
|
)
|
||||||
|
with self.assertRaisesMessage(ValueError, msg):
|
||||||
|
call_command("makemigrations", "migrations", empty=True, verbosity=0)
|
||||||
|
|
||||||
def test_makemigrations_no_changes_no_apps(self):
|
def test_makemigrations_no_changes_no_apps(self):
|
||||||
"""
|
"""
|
||||||
Makes sure that makemigrations exits when there are no changes and no apps are specified.
|
Makes sure that makemigrations exits when there are no changes and no apps are specified.
|
||||||
|
|
Loading…
Reference in New Issue