mirror of
https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
synced 2026-03-05 05:36:54 +08:00
🗃️ 添加 verify 字段到 Bind 模型,并在创建或更新绑定时支持该字段
This commit is contained in:
@@ -0,0 +1,42 @@
|
|||||||
|
"""add verify field
|
||||||
|
|
||||||
|
迁移 ID: 2ff388a8c486
|
||||||
|
父迁移: 3588702dd3a4
|
||||||
|
创建时间: 2025-07-22 18:09:09.734164
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
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 = '2ff388a8c486'
|
||||||
|
down_revision: str | Sequence[str] | None = '3588702dd3a4'
|
||||||
|
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_bind', schema=None) as batch_op:
|
||||||
|
batch_op.add_column(sa.Column('verify', sa.Boolean(), nullable=False, server_default='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_bind', schema=None) as batch_op:
|
||||||
|
batch_op.drop_column('verify')
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
@@ -42,6 +42,8 @@ async def create_or_update_bind(
|
|||||||
user: User,
|
user: User,
|
||||||
game_platform: GameType,
|
game_platform: GameType,
|
||||||
game_account: str,
|
game_account: str,
|
||||||
|
*,
|
||||||
|
verify: bool = False,
|
||||||
) -> BindStatus:
|
) -> BindStatus:
|
||||||
bind = await query_bind_info(
|
bind = await query_bind_info(
|
||||||
session=session,
|
session=session,
|
||||||
@@ -53,6 +55,7 @@ async def create_or_update_bind(
|
|||||||
user_id=user.id,
|
user_id=user.id,
|
||||||
game_platform=game_platform,
|
game_platform=game_platform,
|
||||||
game_account=game_account,
|
game_account=game_account,
|
||||||
|
verify=verify,
|
||||||
)
|
)
|
||||||
session.add(bind)
|
session.add(bind)
|
||||||
status = BindStatus.SUCCESS
|
status = BindStatus.SUCCESS
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ class Bind(MappedAsDataclass, Model):
|
|||||||
user_id: Mapped[int] = mapped_column(index=True)
|
user_id: Mapped[int] = mapped_column(index=True)
|
||||||
game_platform: Mapped[GameType] = mapped_column(String(32))
|
game_platform: Mapped[GameType] = mapped_column(String(32))
|
||||||
game_account: Mapped[str]
|
game_account: Mapped[str]
|
||||||
|
verify: Mapped[bool]
|
||||||
|
|
||||||
|
|
||||||
class TriggerHistoricalDataV2(MappedAsDataclass, Model):
|
class TriggerHistoricalDataV2(MappedAsDataclass, Model):
|
||||||
|
|||||||
Reference in New Issue
Block a user