diff --git a/HISTORY.rst b/HISTORY.rst index 8008971..d7465a0 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -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 + `__. + * Also assume modules in ``dist-packages`` are third-party apps. Thanks to Serkan Hosca for `Pull Request #21 diff --git a/src/django_linear_migrations/apps.py b/src/django_linear_migrations/apps.py index 0aac51e..6d49188 100644 --- a/src/django_linear_migrations/apps.py +++ b/src/django_linear_migrations/apps.py @@ -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 diff --git a/src/django_linear_migrations/management/commands/create-max-migration-files.py b/src/django_linear_migrations/management/commands/create-max-migration-files.py index 3c5f58b..e1b06ad 100644 --- a/src/django_linear_migrations/management/commands/create-max-migration-files.py +++ b/src/django_linear_migrations/management/commands/create-max-migration-files.py @@ -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( diff --git a/tests/test_checks.py b/tests/test_checks.py index ca74c9f..d02545a 100644 --- a/tests/test_checks.py +++ b/tests/test_checks.py @@ -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() @@ -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()