Fix: Handle 'user_agent' data truncation error

This commit is contained in:
咕谷酱
2025-08-22 15:17:03 +08:00
parent e293d7541b
commit 3b1d7a2234
5 changed files with 128 additions and 4 deletions

View File

@@ -0,0 +1,40 @@
"""Increase the length limit of the user_agent field in the login_sessions table
Revision ID: 5b76689f6e4b
Revises: 65e7dc8d5905
Create Date: 2025-08-22 15:14:59.242274
"""
from __future__ import annotations
from collections.abc import Sequence
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
# revision identifiers, used by Alembic.
revision: str = "5b76689f6e4b"
down_revision: str | Sequence[str] | None = "65e7dc8d5905"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column("login_sessions", "user_agent",
existing_type=mysql.VARCHAR(length=255),
type_=sa.String(length=250),
existing_nullable=True)
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column("login_sessions", "user_agent",
existing_type=sa.String(length=250),
type_=mysql.VARCHAR(length=255),
existing_nullable=True)
# ### end Alembic commands ###