From 17c628b686aabec3d08bd13d4ace62f87e4e043f Mon Sep 17 00:00:00 2001 From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Thu, 12 Mar 2026 13:38:01 -0700 Subject: [PATCH] Disables the system checks for most of our commands, as the image has already run them, so we're good enough without them --- docs/migration-v3.md | 24 +++++++++++++++++++ src/documents/management/commands/base.py | 6 +++++ .../management/commands/document_importer.py | 2 +- src/documents/tests/test_api_schema.py | 7 +++++- src/documents/tests/test_management.py | 4 ++-- .../tests/test_management_superuser.py | 1 + src/paperless_mail/tests/test_mail.py | 2 +- 7 files changed, 41 insertions(+), 5 deletions(-) diff --git a/docs/migration-v3.md b/docs/migration-v3.md index 43a3690c0..d1500a788 100644 --- a/docs/migration-v3.md +++ b/docs/migration-v3.md @@ -72,6 +72,30 @@ PAPERLESS_DBHOST: postgres See [`PAPERLESS_DBENGINE`](configuration.md#PAPERLESS_DBENGINE) for accepted values. +## Management Command: `--skip-checks` Removed + +The `--skip-checks` flag has been removed from all Paperless-ngx management commands +(`document_exporter`, `document_importer`, `document_retagger`, `document_archiver`, +`document_thumbnails`, `document_index`, `document_renamer`, `document_sanity_checker`, +`document_fuzzy_match`, and others). + +These commands now set `requires_system_checks = []` internally, which both skips +redundant checks at runtime (they are already run as a dedicated step during Docker +startup via `init-system-checks`) and removes `--skip-checks` from the argument parser. + +#### Action Required + +Remove `--skip-checks` from any scripts, cron jobs, or automation that invokes +these commands: + +```bash +# v2 +document_exporter /backup --skip-checks + +# v3 +document_exporter /backup +``` + ## Database Advanced Options The individual SSL, timeout, and pooling variables have been removed in favor of a diff --git a/src/documents/management/commands/base.py b/src/documents/management/commands/base.py index 1d76460c0..ce2cd60a3 100644 --- a/src/documents/management/commands/base.py +++ b/src/documents/management/commands/base.py @@ -151,6 +151,10 @@ class PaperlessCommand(RichCommand): supports_progress_bar: Adds --no-progress-bar argument (default: True) supports_multiprocessing: Adds --processes argument (default: False) + System checks are skipped by default (requires_system_checks = []) because + these commands run post-startup where checks have already been performed by + the application server. Subclasses that genuinely need checks can override. + Example usage: class Command(PaperlessCommand): @@ -189,6 +193,8 @@ class PaperlessCommand(RichCommand): stats.imported += 1 """ + requires_system_checks: ClassVar[list] = [] + supports_progress_bar: ClassVar[bool] = True supports_multiprocessing: ClassVar[bool] = False diff --git a/src/documents/management/commands/document_importer.py b/src/documents/management/commands/document_importer.py index 20d50e41b..c0056c062 100644 --- a/src/documents/management/commands/document_importer.py +++ b/src/documents/management/commands/document_importer.py @@ -205,7 +205,7 @@ class Command(CryptMixin, PaperlessCommand): ContentType.objects.all().delete() Permission.objects.all().delete() for manifest_path in self.manifest_paths: - call_command("loaddata", manifest_path) + call_command("loaddata", manifest_path, skip_checks=True) except (FieldDoesNotExist, DeserializationError, IntegrityError) as e: self.stdout.write(self.style.ERROR("Database import failed")) if ( diff --git a/src/documents/tests/test_api_schema.py b/src/documents/tests/test_api_schema.py index e14762f68..d8b023e6a 100644 --- a/src/documents/tests/test_api_schema.py +++ b/src/documents/tests/test_api_schema.py @@ -12,7 +12,12 @@ class TestApiSchema(APITestCase): Test that the schema is valid """ try: - call_command("spectacular", "--validate", "--fail-on-warn") + call_command( + "spectacular", + "--validate", + "--fail-on-warn", + skip_checks=True, + ) except CommandError as e: self.fail(f"Schema validation failed: {e}") diff --git a/src/documents/tests/test_management.py b/src/documents/tests/test_management.py index 03959a85b..549b7ca21 100644 --- a/src/documents/tests/test_management.py +++ b/src/documents/tests/test_management.py @@ -140,7 +140,7 @@ class TestCreateClassifier(TestCase): "documents.management.commands.document_create_classifier.train_classifier", ) def test_create_classifier(self, m) -> None: - call_command("document_create_classifier") + call_command("document_create_classifier", skip_checks=True) m.assert_called_once() @@ -152,7 +152,7 @@ class TestConvertMariaDBUUID(TestCase): m.alter_field.return_value = None stdout = StringIO() - call_command("convert_mariadb_uuid", stdout=stdout) + call_command("convert_mariadb_uuid", stdout=stdout, skip_checks=True) m.assert_called_once() diff --git a/src/documents/tests/test_management_superuser.py b/src/documents/tests/test_management_superuser.py index 0a6bcb8cd..f2741ba53 100644 --- a/src/documents/tests/test_management_superuser.py +++ b/src/documents/tests/test_management_superuser.py @@ -20,6 +20,7 @@ class TestManageSuperUser(DirectoriesMixin, TestCase): "--no-color", stdout=out, stderr=StringIO(), + skip_checks=True, ) return out.getvalue() diff --git a/src/paperless_mail/tests/test_mail.py b/src/paperless_mail/tests/test_mail.py index 162a764f2..72ee5331a 100644 --- a/src/paperless_mail/tests/test_mail.py +++ b/src/paperless_mail/tests/test_mail.py @@ -1665,7 +1665,7 @@ class TestManagementCommand(TestCase): "paperless_mail.management.commands.mail_fetcher.tasks.process_mail_accounts", ) def test_mail_fetcher(self, m) -> None: - call_command("mail_fetcher") + call_command("mail_fetcher", skip_checks=True) m.assert_called_once()