"""first revision

迁移 ID: 0ef2cf7a5041
父迁移: 
创建时间: 2025-07-21 16:43:22.667289

"""
from __future__ import annotations

from collections.abc import Sequence

from alembic import op
import sqlalchemy as sa


revision: str = '0ef2cf7a5041'
down_revision: str | Sequence[str] | None = None
branch_labels: str | Sequence[str] | None = ('nonebot_plugin_delta_helper',)
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_delta_helper_latestrecord',
    sa.Column('qq_id', sa.Integer(), nullable=False),
    sa.Column('latest_record_id', sa.String(), nullable=False),
    sa.PrimaryKeyConstraint('qq_id', name=op.f('pk_nonebot_plugin_delta_helper_latestrecord')),
    info={'bind_key': 'nonebot_plugin_delta_helper'}
    )
    op.create_table('nonebot_plugin_delta_helper_userdata',
    sa.Column('qq_id', sa.Integer(), nullable=False),
    sa.Column('group_id', sa.Integer(), nullable=False),
    sa.Column('access_token', sa.String(), nullable=False),
    sa.Column('openid', sa.String(), nullable=False),
    sa.PrimaryKeyConstraint('qq_id', name=op.f('pk_nonebot_plugin_delta_helper_userdata')),
    info={'bind_key': 'nonebot_plugin_delta_helper'}
    )
    op.drop_table('nonebot_session_to_uninfo_id_map')
    op.drop_table('nonebot_plugin_session_orm_sessionmodel')
    op.drop_table('nonebot_plugin_memes_memegenerationrecord')
    # ### end Alembic commands ###


def downgrade(name: str = "") -> None:
    if name:
        return
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('nonebot_plugin_memes_memegenerationrecord',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('session_persist_id', sa.INTEGER(), nullable=False),
    sa.Column('time', sa.DATETIME(), nullable=False),
    sa.Column('meme_key', sa.VARCHAR(length=64), nullable=False),
    sa.PrimaryKeyConstraint('id', name='pk_nonebot_plugin_memes_memegenerationrecord')
    )
    op.create_table('nonebot_plugin_session_orm_sessionmodel',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('bot_id', sa.VARCHAR(length=64), nullable=False),
    sa.Column('bot_type', sa.VARCHAR(length=32), nullable=False),
    sa.Column('platform', sa.VARCHAR(length=32), nullable=False),
    sa.Column('level', sa.INTEGER(), nullable=False),
    sa.Column('id1', sa.VARCHAR(length=64), nullable=False),
    sa.Column('id2', sa.VARCHAR(length=64), nullable=False),
    sa.Column('id3', sa.VARCHAR(length=64), nullable=False),
    sa.PrimaryKeyConstraint('id', name='pk_nonebot_plugin_session_orm_sessionmodel'),
    sa.UniqueConstraint('bot_id', 'bot_type', 'platform', 'level', 'id1', 'id2', 'id3', name='unique_session')
    )
    op.create_table('nonebot_session_to_uninfo_id_map',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('session_id', sa.INTEGER(), nullable=False),
    sa.Column('uninfo_id', sa.INTEGER(), nullable=False),
    sa.PrimaryKeyConstraint('id', name='pk_nonebot_session_to_uninfo_id_map'),
    sa.UniqueConstraint('session_id', 'uninfo_id', name='unique_map')
    )
    op.drop_table('nonebot_plugin_delta_helper_userdata')
    op.drop_table('nonebot_plugin_delta_helper_latestrecord')
    # ### end Alembic commands ###
