"""init trumpwatcher tables

迁移 ID: 2d4f1be060eb
父迁移: 
创建时间: 2026-03-05 12:53:14.934012

"""
from __future__ import annotations

from collections.abc import Sequence

from alembic import op
import sqlalchemy as sa


revision: str = '2d4f1be060eb'
down_revision: str | Sequence[str] | None = None
branch_labels: str | Sequence[str] | None = ('nonebot_plugin_trumpwatcher',)
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('trumpwatcher_notify_group',
    sa.Column('group_id', sa.BigInteger(), nullable=False),
    sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
    sa.PrimaryKeyConstraint('group_id', name=op.f('pk_trumpwatcher_notify_group')),
    info={'bind_key': 'nonebot_plugin_trumpwatcher'}
    )
    op.create_table('trumpwatcher_post_archive',
    sa.Column('post_id', sa.String(length=32), nullable=False),
    sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
    sa.Column('content', sa.Text(), nullable=False),
    sa.Column('url', sa.String(length=255), nullable=False),
    sa.Column('media_text', sa.Text(), nullable=False),
    sa.Column('fetched_at', sa.DateTime(timezone=True), nullable=False),
    sa.PrimaryKeyConstraint('post_id', name=op.f('pk_trumpwatcher_post_archive')),
    info={'bind_key': 'nonebot_plugin_trumpwatcher'}
    )
    with op.batch_alter_table('trumpwatcher_post_archive', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_trumpwatcher_post_archive_created_at'), ['created_at'], 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('trumpwatcher_post_archive', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_trumpwatcher_post_archive_created_at'))

    op.drop_table('trumpwatcher_post_archive')
    op.drop_table('trumpwatcher_notify_group')
    # ### end Alembic commands ###
