mirror of
https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
synced 2026-03-05 05:36:54 +08:00
* 🔧 启用一些 ruff 的新规则 * ➕ 添加开发依赖 nonebot-adapter-qq * ➕ 添加依赖 nonebot-plugin-session * ➕ 添加依赖 nonebot-plugin-session-orm * 🔧 忽略 ruff 规则 ISC001 format 冲突风险 * 🚨 修复 ruff 警报 * ♻️ 重构! * ♻️ 恢复定时获取 TetraLeague 数据的功能 * ✨ 统一处理需要捕获的错误 * ✨ 记录用户触发的指令
144 lines
6.1 KiB
Python
144 lines
6.1 KiB
Python
"""init db
|
|
|
|
迁移 ID: 9866f53ce44f
|
|
父迁移:
|
|
创建时间: 2023-11-11 16:24:11.826667
|
|
|
|
"""
|
|
|
|
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 = '9866f53ce44f'
|
|
down_revision: str | Sequence[str] | None = None
|
|
branch_labels: str | Sequence[str] | None = ('nonebot_plugin_tetris_stats',)
|
|
depends_on: str | Sequence[str] | None = None
|
|
|
|
|
|
def upgrade(name: str = '') -> None:
|
|
if name:
|
|
return
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table(
|
|
'nonebot_plugin_tetris_stats_bind',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('chat_platform', sa.String(length=32), nullable=False),
|
|
sa.Column('chat_account', sa.String(), nullable=False),
|
|
sa.Column('game_platform', sa.String(length=32), nullable=False),
|
|
sa.Column('game_account', sa.String(), nullable=False),
|
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_nonebot_plugin_tetris_stats_bind')),
|
|
)
|
|
with op.batch_alter_table('nonebot_plugin_tetris_stats_bind', schema=None) as batch_op:
|
|
batch_op.create_index(
|
|
batch_op.f('ix_nonebot_plugin_tetris_stats_bind_chat_account'),
|
|
['chat_account'],
|
|
unique=False,
|
|
)
|
|
batch_op.create_index(
|
|
batch_op.f('ix_nonebot_plugin_tetris_stats_bind_chat_platform'),
|
|
['chat_platform'],
|
|
unique=False,
|
|
)
|
|
|
|
op.create_table(
|
|
'nonebot_plugin_tetris_stats_historicaldata',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('trigger_time', sa.DateTime(), nullable=False),
|
|
sa.Column('bot_platform', sa.String(length=32), nullable=True),
|
|
sa.Column('bot_account', sa.String(), nullable=True),
|
|
sa.Column('source_type', sa.String(length=32), nullable=True),
|
|
sa.Column('source_account', sa.String(), nullable=True),
|
|
sa.Column('message', sa.PickleType(), nullable=True),
|
|
sa.Column('game_platform', sa.String(length=32), nullable=False),
|
|
sa.Column('command_type', sa.String(length=16), nullable=False),
|
|
sa.Column('command_args', sa.JSON(), nullable=False),
|
|
sa.Column('game_user', sa.PickleType(), nullable=False),
|
|
sa.Column('processed_data', sa.PickleType(), nullable=False),
|
|
sa.Column('finish_time', sa.DateTime(), nullable=False),
|
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_nonebot_plugin_tetris_stats_historicaldata')),
|
|
)
|
|
with op.batch_alter_table('nonebot_plugin_tetris_stats_historicaldata', schema=None) as batch_op:
|
|
batch_op.create_index(
|
|
batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_command_type'),
|
|
['command_type'],
|
|
unique=False,
|
|
)
|
|
batch_op.create_index(
|
|
batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_game_platform'),
|
|
['game_platform'],
|
|
unique=False,
|
|
)
|
|
batch_op.create_index(
|
|
batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_source_account'),
|
|
['source_account'],
|
|
unique=False,
|
|
)
|
|
batch_op.create_index(
|
|
batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_source_type'),
|
|
['source_type'],
|
|
unique=False,
|
|
)
|
|
|
|
op.create_table(
|
|
'nonebot_plugin_tetris_stats_iorank',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('rank', sa.String(length=2), nullable=False),
|
|
sa.Column('tr_line', sa.Float(), nullable=False),
|
|
sa.Column('player_count', sa.Integer(), nullable=False),
|
|
sa.Column('low_pps', sa.JSON(), nullable=False),
|
|
sa.Column('low_apm', sa.JSON(), nullable=False),
|
|
sa.Column('low_vs', sa.JSON(), nullable=False),
|
|
sa.Column('avg_pps', sa.Float(), nullable=False),
|
|
sa.Column('avg_apm', sa.Float(), nullable=False),
|
|
sa.Column('avg_vs', sa.Float(), nullable=False),
|
|
sa.Column('high_pps', sa.JSON(), nullable=False),
|
|
sa.Column('high_apm', sa.JSON(), nullable=False),
|
|
sa.Column('high_vs', sa.JSON(), nullable=False),
|
|
sa.Column('create_time', sa.DateTime(), nullable=False),
|
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_nonebot_plugin_tetris_stats_iorank')),
|
|
)
|
|
with op.batch_alter_table('nonebot_plugin_tetris_stats_iorank', schema=None) as batch_op:
|
|
batch_op.create_index(
|
|
batch_op.f('ix_nonebot_plugin_tetris_stats_iorank_create_time'),
|
|
['create_time'],
|
|
unique=False,
|
|
)
|
|
batch_op.create_index(
|
|
batch_op.f('ix_nonebot_plugin_tetris_stats_iorank_rank'),
|
|
['rank'],
|
|
unique=False,
|
|
)
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade(name: str = '') -> None:
|
|
if name:
|
|
return
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table('nonebot_plugin_tetris_stats_iorank', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_iorank_rank'))
|
|
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_iorank_create_time'))
|
|
|
|
op.drop_table('nonebot_plugin_tetris_stats_iorank')
|
|
with op.batch_alter_table('nonebot_plugin_tetris_stats_historicaldata', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_source_type'))
|
|
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_source_account'))
|
|
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_game_platform'))
|
|
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_command_type'))
|
|
|
|
op.drop_table('nonebot_plugin_tetris_stats_historicaldata')
|
|
with op.batch_alter_table('nonebot_plugin_tetris_stats_bind', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_bind_chat_platform'))
|
|
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_bind_chat_account'))
|
|
|
|
op.drop_table('nonebot_plugin_tetris_stats_bind')
|
|
# ### end Alembic commands ###
|