mirror of
https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
synced 2026-03-05 05:36:54 +08:00
🗃️ 增加 TETRIOHistoricalData.api_type 字段长度
This commit is contained in:
@@ -0,0 +1,50 @@
|
|||||||
|
"""Extend api_type field length
|
||||||
|
|
||||||
|
迁移 ID: cfeab6961dce
|
||||||
|
父迁移: f5b4a6d1325b
|
||||||
|
创建时间: 2024-08-09 14:20:59.789030
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from alembic import op
|
||||||
|
from nonebot.log import logger
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from collections.abc import Sequence
|
||||||
|
|
||||||
|
revision: str = 'cfeab6961dce'
|
||||||
|
down_revision: str | Sequence[str] | None = 'f5b4a6d1325b'
|
||||||
|
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('nonebot_plugin_tetris_stats_tetriohistoricaldata', schema=None) as batch_op:
|
||||||
|
batch_op.alter_column(
|
||||||
|
'api_type', existing_type=sa.VARCHAR(length=16), type_=sa.String(length=32), existing_nullable=False
|
||||||
|
)
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade(name: str = '') -> None:
|
||||||
|
if name:
|
||||||
|
return
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
logger.warning('新数据可能不支持降级!')
|
||||||
|
logger.warning('请确认数据库内数据可以迁移到旧版本!')
|
||||||
|
input('如果确认可以迁移, 请按回车键继续!')
|
||||||
|
with op.batch_alter_table('nonebot_plugin_tetris_stats_tetriohistoricaldata', schema=None) as batch_op:
|
||||||
|
batch_op.alter_column(
|
||||||
|
'api_type', existing_type=sa.String(length=32), type_=sa.VARCHAR(length=16), existing_nullable=False
|
||||||
|
)
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
@@ -13,6 +13,6 @@ from .typing import Summaries
|
|||||||
class TETRIOHistoricalData(MappedAsDataclass, Model):
|
class TETRIOHistoricalData(MappedAsDataclass, Model):
|
||||||
id: Mapped[int] = mapped_column(init=False, primary_key=True)
|
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(24), index=True)
|
||||||
api_type: Mapped[Literal['User Info', Summaries]] = mapped_column(String(16), index=True)
|
api_type: Mapped[Literal['User Info', Summaries]] = mapped_column(String(32), index=True)
|
||||||
data: Mapped[SuccessModel] = mapped_column(PydanticType(get_model=[SuccessModel.__subclasses__], models=set()))
|
data: Mapped[SuccessModel] = mapped_column(PydanticType(get_model=[SuccessModel.__subclasses__], models=set()))
|
||||||
update_time: Mapped[datetime] = mapped_column(DateTime, index=True)
|
update_time: Mapped[datetime] = mapped_column(DateTime, index=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user