diff --git a/nonebot_plugin_tetris_stats/config/migrations/3588702dd3a4_modify_field_length.py b/nonebot_plugin_tetris_stats/config/migrations/3588702dd3a4_modify_field_length.py new file mode 100644 index 0000000..2860367 --- /dev/null +++ b/nonebot_plugin_tetris_stats/config/migrations/3588702dd3a4_modify_field_length.py @@ -0,0 +1,52 @@ +"""modify field length + +迁移 ID: 3588702dd3a4 +父迁移: bc6abd57928f +创建时间: 2025-07-19 17:21:17.927162 + +""" + +from __future__ import annotations + +from typing import TYPE_CHECKING + +import sqlalchemy as sa +from alembic import op + +if TYPE_CHECKING: + from collections.abc import Sequence + +revision: str = '3588702dd3a4' +down_revision: str | Sequence[str] | None = 'bc6abd57928f' +branch_labels: str | Sequence[str] | None = None +depends_on: str | Sequence[str] | None = None + + +def upgrade(name: str = '') -> None: + if name: + return + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('nb_t_tos_hist_data', schema=None) as batch_op: + batch_op.alter_column( + 'user_unique_identifier', + existing_type=sa.VARCHAR(length=24), + type_=sa.String(length=256), + existing_nullable=False, + ) + + # ### end Alembic commands ### + + +def downgrade(name: str = '') -> None: + if name: + return + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('nb_t_tos_hist_data', schema=None) as batch_op: + batch_op.alter_column( + 'user_unique_identifier', + existing_type=sa.String(length=256), + type_=sa.VARCHAR(length=24), + existing_nullable=False, + ) + + # ### end Alembic commands ### diff --git a/nonebot_plugin_tetris_stats/games/tos/api/models.py b/nonebot_plugin_tetris_stats/games/tos/api/models.py index f7c329d..8a39abe 100644 --- a/nonebot_plugin_tetris_stats/games/tos/api/models.py +++ b/nonebot_plugin_tetris_stats/games/tos/api/models.py @@ -14,7 +14,7 @@ class TOSHistoricalData(MappedAsDataclass, Model): __tablename__ = 'nb_t_tos_hist_data' id: Mapped[int] = mapped_column(init=False, primary_key=True) - user_unique_identifier: Mapped[str] = mapped_column(String(24), index=True) + user_unique_identifier: Mapped[str] = mapped_column(String(256), index=True) api_type: Mapped[Literal['User Info', 'User Profile']] = mapped_column(String(16), index=True) data: Mapped[UserInfoSuccess | UserProfile] = mapped_column( PydanticType(get_model=[], models={UserInfoSuccess, UserProfile})