04/17 Update: widen system setting value

This commit is contained in:
2026-04-17 14:36:44 -04:00
parent 25af7a836d
commit bcbb56cb7e
2 changed files with 56 additions and 1 deletions
+1 -1
View File
@@ -327,7 +327,7 @@ class SystemSetting(db.Model):
id = db.Column(db.Integer, primary_key=True)
key = db.Column(db.String(100), unique=True, nullable=False, index=True)
value = db.Column(db.String(500), nullable=False)
value = db.Column(db.Text, nullable=False)
description = db.Column(db.String(256))
updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
@@ -0,0 +1,55 @@
"""Widen system_settings value from VARCHAR(500) to TEXT
Revision ID: 004_widen_system_setting_value
Revises: 003_render_comments
Create Date: 2026-04-17
Rationale
---------
SystemSetting.value was VARCHAR(500), which is sufficient for short config
values but overflows when the email_ingested_message_ids key accumulates
multiple Outlook Message-IDs. A single Outlook Message-ID can be ~100 chars,
so even a modest backlog of 67 messages exceeds the 500-byte limit, causing:
pymysql.err.DataError: (1406, "Data too long for column 'value' at row 1")
TEXT (up to 65,535 bytes) is the correct type for any value store that can
hold accumulated lists or free-form strings of unbounded length. This mirrors
the same fix applied to ticket_history in migration 001.
Apply
-----
flask db upgrade
Rollback
--------
flask db downgrade
"""
from alembic import op
import sqlalchemy as sa
revision = '004_widen_system_setting_value'
down_revision = '003_render_comments'
branch_labels = None
depends_on = None
def upgrade():
with op.batch_alter_table('system_settings', schema=None) as batch_op:
batch_op.alter_column(
'value',
existing_type=sa.String(length=500),
type_=sa.Text(),
existing_nullable=False,
)
def downgrade():
with op.batch_alter_table('system_settings', schema=None) as batch_op:
batch_op.alter_column(
'value',
existing_type=sa.Text(),
type_=sa.String(length=500),
existing_nullable=False,
)