"""change dcid type

迁移 ID: 5fb7a7432778
父迁移: ca5c07252665
创建时间: 2025-07-06 16:40:46.261312

"""

from __future__ import annotations

from collections.abc import Sequence

from alembic import op
import sqlalchemy as sa

revision: str = "5fb7a7432778"
down_revision: str | Sequence[str] | None = "ca5c07252665"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade(name: str = "") -> None:
    if name:
        return
    # ### commands auto generated by Alembic - please adjust! ###
    bind = op.get_bind()
    if bind.engine.name == "sqlite":
        with op.batch_alter_table("nonebot_plugin_dcqq_relay_msgid") as op_batch:
            op_batch.alter_column("dcid", nullable=False, type_=sa.BigInteger())
    else:
        op.alter_column(
            "nonebot_plugin_dcqq_relay_msgid",
            "dcid",
            nullable=False,
            type_=sa.BigInteger(),
        )
    # ### end Alembic commands ###


def downgrade(name: str = "") -> None:
    if name:
        return
    # ### commands auto generated by Alembic - please adjust! ###
    bind = op.get_bind()
    if bind.engine.name == "sqlite":
        with op.batch_alter_table("nonebot_plugin_dcqq_relay_msgid") as op_batch:
            op_batch.alter_column(
                "dcid",
                nullable=False,
                type_=sa.Integer(),
                existing_type=sa.BigInteger(),
            )
    else:
        op.alter_column(
            "nonebot_plugin_dcqq_relay_msgid",
            "dcid",
            nullable=False,
            type_=sa.Integer(),
            existing_type=sa.BigInteger(),
        )
    # ### end Alembic commands ###
