Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made check for whether migrations exist consistent #22

Merged
merged 1 commit into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
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