mirror of
https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
synced 2026-02-03 18:45:32 +08:00
* 🗃️ 自定义表名 * ➕ 添加开发依赖 nonebot-plugin-orm[postgresql] * 🗃️ postgresql 跳过所有旧迁移脚本 * 🗃️ 修正方言 * 🗃️ 添加迁移脚本 * 🚨 auto fix by pre-commit hooks * 🚨 添加一个 noqa( --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
124 lines
5.4 KiB
Python
124 lines
5.4 KiB
Python
"""add TETRIOLeagueStats
|
|
|
|
迁移 ID: 5a1b93948494
|
|
父迁移: cfeab6961dce
|
|
创建时间: 2024-08-24 00:22:41.359500
|
|
|
|
"""
|
|
|
|
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 = '5a1b93948494'
|
|
down_revision: str | Sequence[str] | None = 'cfeab6961dce'
|
|
branch_labels: str | Sequence[str] | None = None
|
|
depends_on: str | Sequence[str] | None = None
|
|
|
|
|
|
def upgrade(name: str = '') -> None:
|
|
if name:
|
|
return
|
|
if op.get_bind().dialect.name == 'postgresql':
|
|
return
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table(
|
|
'nonebot_plugin_tetris_stats_tetrioleaguestats',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('update_time', sa.DateTime(), nullable=False),
|
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_nonebot_plugin_tetris_stats_tetrioleaguestats')),
|
|
info={'bind_key': 'nonebot_plugin_tetris_stats'},
|
|
)
|
|
with op.batch_alter_table('nonebot_plugin_tetris_stats_tetrioleaguestats', schema=None) as batch_op:
|
|
batch_op.create_index(
|
|
batch_op.f('ix_nonebot_plugin_tetris_stats_tetrioleaguestats_update_time'), ['update_time'], unique=False
|
|
)
|
|
|
|
op.create_table(
|
|
'nonebot_plugin_tetris_stats_tetrioleaguehistorical',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('request_id', sa.Uuid(), nullable=False),
|
|
sa.Column('data', sa.JSON(), nullable=False),
|
|
sa.Column('update_time', sa.DateTime(), nullable=False),
|
|
sa.Column('stats_id', sa.Integer(), nullable=False),
|
|
sa.ForeignKeyConstraint(
|
|
['stats_id'],
|
|
['nonebot_plugin_tetris_stats_tetrioleaguestats.id'],
|
|
name=op.f(
|
|
'fk_nonebot_plugin_tetris_stats_tetrioleaguehistorical_stats_id_nonebot_plugin_tetris_stats_tetrioleaguestats'
|
|
),
|
|
),
|
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_nonebot_plugin_tetris_stats_tetrioleaguehistorical')),
|
|
info={'bind_key': 'nonebot_plugin_tetris_stats'},
|
|
)
|
|
with op.batch_alter_table('nonebot_plugin_tetris_stats_tetrioleaguehistorical', schema=None) as batch_op:
|
|
batch_op.create_index(
|
|
batch_op.f('ix_nonebot_plugin_tetris_stats_tetrioleaguehistorical_request_id'), ['request_id'], unique=False
|
|
)
|
|
batch_op.create_index(
|
|
batch_op.f('ix_nonebot_plugin_tetris_stats_tetrioleaguehistorical_update_time'),
|
|
['update_time'],
|
|
unique=False,
|
|
)
|
|
|
|
op.create_table(
|
|
'nonebot_plugin_tetris_stats_tetrioleaguestatsfield',
|
|
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('stats_id', sa.Integer(), nullable=False),
|
|
sa.ForeignKeyConstraint(
|
|
['stats_id'],
|
|
['nonebot_plugin_tetris_stats_tetrioleaguestats.id'],
|
|
name=op.f(
|
|
'fk_nonebot_plugin_tetris_stats_tetrioleaguestatsfield_stats_id_nonebot_plugin_tetris_stats_tetrioleaguestats'
|
|
),
|
|
),
|
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_nonebot_plugin_tetris_stats_tetrioleaguestatsfield')),
|
|
info={'bind_key': 'nonebot_plugin_tetris_stats'},
|
|
)
|
|
with op.batch_alter_table('nonebot_plugin_tetris_stats_tetrioleaguestatsfield', schema=None) as batch_op:
|
|
batch_op.create_index(
|
|
batch_op.f('ix_nonebot_plugin_tetris_stats_tetrioleaguestatsfield_rank'), ['rank'], unique=False
|
|
)
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade(name: str = '') -> None:
|
|
if name:
|
|
return
|
|
if op.get_bind().dialect.name == 'postgresql':
|
|
return
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table('nonebot_plugin_tetris_stats_tetrioleaguestatsfield', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_tetrioleaguestatsfield_rank'))
|
|
|
|
op.drop_table('nonebot_plugin_tetris_stats_tetrioleaguestatsfield')
|
|
with op.batch_alter_table('nonebot_plugin_tetris_stats_tetrioleaguehistorical', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_tetrioleaguehistorical_update_time'))
|
|
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_tetrioleaguehistorical_request_id'))
|
|
|
|
op.drop_table('nonebot_plugin_tetris_stats_tetrioleaguehistorical')
|
|
with op.batch_alter_table('nonebot_plugin_tetris_stats_tetrioleaguestats', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_tetrioleaguestats_update_time'))
|
|
|
|
op.drop_table('nonebot_plugin_tetris_stats_tetrioleaguestats')
|
|
# ### end Alembic commands ###
|