mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-07-25 21:34:54 +00:00
Avoids a Postgres error where the clamp UPDATE and the following ALTER TABLE on paperless_mail_mailrule share a transaction, but the table's FKs are deferrable, so pending trigger events block the ALTER. Also fixes a verbose_name mismatch in migration 0013.
This commit is contained in:
@@ -17,7 +17,7 @@ class Migration(migrations.Migration):
|
||||
field=models.PositiveSmallIntegerField(
|
||||
null=True,
|
||||
validators=[django.core.validators.MinValueValidator(1)],
|
||||
verbose_name="Sets the LLM request timeout in seconds",
|
||||
verbose_name="Sets the LLM timeout in seconds",
|
||||
),
|
||||
),
|
||||
]
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
# Split out of 0002_optimize_integer_field_sizes.py into its own migration
|
||||
# (own transaction). Running this UPDATE in the same transaction as the
|
||||
# later ALTER TABLE on paperless_mail_mailrule can fail on PostgreSQL with
|
||||
# "cannot ALTER TABLE because it has pending trigger events", since the
|
||||
# update queues FK trigger events against that table that are still pending
|
||||
# when the subsequent AlterField tries to rewrite it. Committing the clamp
|
||||
# here first avoids that.
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
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"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
clamp_mailrule_maximum_age,
|
||||
migrations.RunPython.noop,
|
||||
),
|
||||
]
|
||||
@@ -4,15 +4,9 @@ from django.db import migrations
|
||||
from 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"),
|
||||
("paperless_mail", "0001_1_clamp_mailrule_maximum_age"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
@@ -118,10 +112,6 @@ 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",
|
||||
|
||||
Reference in New Issue
Block a user