Skip to content

Commit

Permalink
Made check for whether migrations exist consistent
Browse files Browse the repository at this point in the history
Fixes #20
  • Loading branch information
adamchainz committed Dec 14, 2020
1 parent a805d0f commit a3967f6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
History
=======

* Made check for whether migrations exist consistent between the system checks
and ``create-max-migration-files``.

Thanks to @ahumeau for the report in `Issue #20
<https://github.com/adamchainz/django-linear-migrations/issues/20>`__.

* Also assume modules in ``dist-packages`` are third-party apps.

Thanks to Serkan Hosca for `Pull Request #21
Expand Down
1 change: 1 addition & 0 deletions src/django_linear_migrations/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def has_migrations(self):
and not is_namespace_module(self.migrations_module)
# Django ignores non-package migrations modules
and hasattr(self.migrations_module, "__path__")
and len(self.names) > 0
)

@cached_property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def handle(self, *app_labels, **options):
continue

max_migration_txt = migration_details.dir / "max_migration.txt"
if not max_migration_txt.exists() and len(migration_details.names) > 0:
if not max_migration_txt.exists():
max_migration_name = max(migration_details.names)
max_migration_txt.write_text(max_migration_name + "\n")
self.stdout.write(
Expand Down
2 changes: 2 additions & 0 deletions tests/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def test_skipped_unspecified_app(self):

def test_dlm_E001(self):
(self.migrations_dir / "__init__.py").touch()
(self.migrations_dir / "0001_initial.py").touch()

result = check_max_migration_files()

Expand All @@ -60,6 +61,7 @@ def test_dlm_E001(self):

def test_dlm_E002(self):
(self.migrations_dir / "__init__.py").touch()
(self.migrations_dir / "0001_initial.py").touch()
(self.migrations_dir / "max_migration.txt").write_text("line1\nline2\n")

result = check_max_migration_files()
Expand Down

0 comments on commit a3967f6

Please sign in to comment.