A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fix: clamp mailrule max age before migration (#13093)
shamoone145fe8cc767
diff --git a/docs/migration-v3.md b/docs/migration-v3.mdindex 4fff1f858..eece9b744 100644--- a/docs/migration-v3.md+++ b/docs/migration-v3.md@@ -326,3 +326,11 @@ behind a reverse proxy may need to set[`PAPERLESS_TRUSTED_PROXIES`](configuration.md#PAPERLESS_TRUSTED_PROXIES),[`PAPERLESS_ALLAUTH_TRUSTED_CLIENT_IP_HEADER`](configuration.md#PAPERLESS_ALLAUTH_TRUSTED_CLIENT_IP_HEADER),or both, to avoid `403 Forbidden` errors on login.++## Database Migrations++Some integer fields have been changed to smaller types to reduce database size. If you have any `MailRule` records with a `maximum_age` greater than 32767, they will be clamped to 32767 during the migration to avoid errors during migration.++### Action Required++No user action is required. The migration will automatically clamp any `MailRule.maximum_age` values greater than 32767 to 32767 during the migration process.diff --git a/src/paperless_mail/migrations/0002_optimize_integer_field_sizes.py b/src/paperless_mail/migrations/0002_optimize_integer_field_sizes.pyindex bfb66a156..ac8c52d3e 100644--- a/src/paperless_mail/migrations/0002_optimize_integer_field_sizes.py+++ b/src/paperless_mail/migrations/0002_optimize_integer_field_sizes.py@@ -4,6 +4,12 @@ from django.db import migrationsfrom django.db import models+def clamp_mailrule_maximum_age(apps, schema_editor):+ # Clamp the maximum_age field of MailRule because of PositiveIntegerField --> PositiveSmallIntegerField+ MailRule = apps.get_model("paperless_mail", "MailRule")+ MailRule.objects.filter(maximum_age__gt=32767).update(maximum_age=32767)++class Migration(migrations.Migration):dependencies = [("paperless_mail", "0001_squashed"),@@ -112,6 +118,10 @@ class Migration(migrations.Migration):verbose_name="consumption scope",),),+ migrations.RunPython(+ clamp_mailrule_maximum_age,+ migrations.RunPython.noop,+ ),migrations.AlterField(model_name="mailrule",name="maximum_age",