Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions syzygy/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ def check_migrations(app_configs, **kwargs):
except ImportError:
# This is not the place to deal with migration issues.
continue
if module.__file__ is None:
# Skip empty migration folders, which can happen
# for example when switching between branches.
continue
directory = os.path.dirname(module.__file__)

migration_names = set()
for name in os.listdir(directory):
if name.endswith(".py"):
Expand Down
7 changes: 7 additions & 0 deletions tests/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,10 @@ def test_ambiguous_stage(self):
id="migrations.0001",
),
)

def test_empty_migration_folder(self):
with self.settings(MIGRATION_MODULES={"tests": "tests.test_migrations.empty"}):
checks = run_checks(
app_configs=[apps.get_app_config("tests")], tags={"migrations"}
)
self.assertEqual(len(checks), 0)
1 change: 1 addition & 0 deletions tests/test_migrations/empty/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First time I actually did this. This is how one is supposed to force an empty folder in git.