From 0348a5d66cbc37417c33f0d42762f43071f7a164 Mon Sep 17 00:00:00 2001 From: ProgramRipper Date: Sun, 30 Mar 2025 11:36:32 +0800 Subject: [PATCH] :bug: fix: add migrations (#50) --- .../migrations/873ad3421460_.py | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 nonebot_plugin_dialectlist/migrations/873ad3421460_.py diff --git a/nonebot_plugin_dialectlist/migrations/873ad3421460_.py b/nonebot_plugin_dialectlist/migrations/873ad3421460_.py new file mode 100644 index 0000000..f10d8c9 --- /dev/null +++ b/nonebot_plugin_dialectlist/migrations/873ad3421460_.py @@ -0,0 +1,61 @@ +"""empty message + +迁移 ID: 873ad3421460 +父迁移: +创建时间: 2025-03-29 14:30:11.910461 + +""" + +from __future__ import annotations + +from collections.abc import Sequence + +import sqlalchemy as sa +from alembic import op + +revision: str = "873ad3421460" +down_revision: str | Sequence[str] | None = None +branch_labels: str | Sequence[str] | None = ("nonebot_plugin_dialectlist",) +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_dialectlist_messagecountcache", + sa.Column("id", sa.Integer(), autoincrement=True, nullable=False), + sa.Column("time", sa.DateTime(), nullable=False), + sa.Column("session_id", sa.Integer(), nullable=False), + sa.Column("session_bnum", sa.Integer(), nullable=False), + sa.PrimaryKeyConstraint( + "id", name=op.f("pk_nonebot_plugin_dialectlist_messagecountcache") + ), + info={"bind_key": "nonebot_plugin_dialectlist"}, + ) + with op.batch_alter_table( + "nonebot_plugin_dialectlist_messagecountcache", schema=None + ) as batch_op: + batch_op.create_index( + batch_op.f("ix_nonebot_plugin_dialectlist_messagecountcache_session_id"), + ["session_id"], + 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_dialectlist_messagecountcache", schema=None + ) as batch_op: + batch_op.drop_index( + batch_op.f("ix_nonebot_plugin_dialectlist_messagecountcache_session_id") + ) + + op.drop_table("nonebot_plugin_dialectlist_messagecountcache") + # ### end Alembic commands ###