mirror of https://github.com/django/django.git
Fixed #29749 -- Made the migrations loader ignore files starting with a tilde or underscore.
Regression in 29150d5da8
.
This commit is contained in:
parent
a4d8e412e0
commit
32fbccab40
|
@ -97,7 +97,10 @@ class MigrationLoader:
|
|||
if was_loaded:
|
||||
reload(module)
|
||||
self.migrated_apps.add(app_config.label)
|
||||
migration_names = {name for _, name, is_pkg in pkgutil.iter_modules(module.__path__) if not is_pkg}
|
||||
migration_names = {
|
||||
name for _, name, is_pkg in pkgutil.iter_modules(module.__path__)
|
||||
if not is_pkg and name[0] not in '_~'
|
||||
}
|
||||
# Load migrations
|
||||
for migration_name in migration_names:
|
||||
migration_path = '%s.%s' % (module_name, migration_name)
|
||||
|
|
|
@ -11,3 +11,6 @@ Bugfixes
|
|||
|
||||
* Fixed a regression where nonexistent joins in ``F()`` no longer raised
|
||||
``FieldError`` (:ticket:`29727`).
|
||||
|
||||
* Fixed a regression where files starting with a tilde or underscore weren't
|
||||
ignored by the migrations loader (:ticket:`29749`).
|
||||
|
|
|
@ -500,6 +500,14 @@ class LoaderTests(TestCase):
|
|||
}
|
||||
self.assertEqual(plan, expected_plan)
|
||||
|
||||
@override_settings(MIGRATION_MODULES={'migrations': 'migrations.test_migrations_private'})
|
||||
def test_ignore_files(self):
|
||||
"""Files prefixed with underscore, tilde, or dot aren't loaded."""
|
||||
loader = MigrationLoader(connection)
|
||||
loader.load_disk()
|
||||
migrations = [name for app, name in loader.disk_migrations if app == 'migrations']
|
||||
self.assertEqual(migrations, ['0001_initial'])
|
||||
|
||||
|
||||
class PycLoaderTests(MigrationTestBase):
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
pass
|
Loading…
Reference in New Issue