Fix some issues

This commit is contained in:
2026-03-26 13:18:09 -04:00
parent ae6a44199f
commit 169820240a
25 changed files with 319 additions and 38 deletions
+31
View File
@@ -0,0 +1,31 @@
from logging.config import fileConfig
from flask import current_app
from alembic import context
config = context.config
if config.config_file_name is not None:
fileConfig(config.config_file_name)
target_metadata = current_app.extensions['migrate'].db.metadata
def run_migrations_offline():
url = config.get_main_option("sqlalchemy.url")
context.configure(url=url, target_metadata=target_metadata,
literal_binds=True, dialect_opts={"paramstyle": "named"})
with context.begin_transaction():
context.run_migrations()
def run_migrations_online():
connectable = current_app.extensions['migrate'].db.engine
with connectable.connect() as connection:
context.configure(connection=connection, target_metadata=target_metadata)
with context.begin_transaction():
context.run_migrations()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()
@@ -0,0 +1,61 @@
"""Widen ticket_history old_value / new_value from VARCHAR(200) to TEXT
Revision ID: 001_widen_ticket_history_values
Revises:
Create Date: 2026-03-26
Rationale
---------
TicketHistory.old_value and new_value were VARCHAR(200), which would cause
a DataError (string too long) or silent truncation if a long internal_notes
or resolution_notes value were ever stored in ticket history. TEXT has no
practical upper-bound and is the correct type for free-form field snapshots.
Apply
-----
flask db upgrade
Rollback
--------
flask db downgrade
"""
from alembic import op
import sqlalchemy as sa
revision = '001_widen_ticket_history_values'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
with op.batch_alter_table('ticket_history', schema=None) as batch_op:
batch_op.alter_column(
'old_value',
existing_type=sa.String(length=200),
type_=sa.Text(),
existing_nullable=True,
)
batch_op.alter_column(
'new_value',
existing_type=sa.String(length=200),
type_=sa.Text(),
existing_nullable=True,
)
def downgrade():
with op.batch_alter_table('ticket_history', schema=None) as batch_op:
batch_op.alter_column(
'new_value',
existing_type=sa.Text(),
type_=sa.String(length=200),
existing_nullable=True,
)
batch_op.alter_column(
'old_value',
existing_type=sa.Text(),
type_=sa.String(length=200),
existing_nullable=True,
)