"""add slack_task_messages

Revision ID: 883488224db5
Revises: a5f862b9d770
Create Date: 2026-05-04 11:59:07.703224

"""

from __future__ import annotations

from collections.abc import Sequence

import sqlalchemy as sa
import sqlmodel

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "883488224db5"
down_revision: str | None = "a5f862b9d770"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "slack_task_messages",
        sa.Column("id", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
        sa.Column("task_id", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
        sa.Column("channel", sqlmodel.sql.sqltypes.AutoString(length=64), nullable=False),
        sa.Column("ts", sqlmodel.sql.sqltypes.AutoString(length=64), nullable=False),
        sa.Column("team_id", sqlmodel.sql.sqltypes.AutoString(length=64), nullable=True),
        sa.Column("created_at", sa.DateTime(), nullable=False),
        sa.ForeignKeyConstraint(
            ["task_id"],
            ["tasks.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
    )
    with op.batch_alter_table("slack_task_messages", schema=None) as batch_op:
        batch_op.create_index(
            batch_op.f("ix_slack_task_messages_task_id"), ["task_id"], unique=False
        )

    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table("slack_task_messages", schema=None) as batch_op:
        batch_op.drop_index(batch_op.f("ix_slack_task_messages_task_id"))

    op.drop_table("slack_task_messages")
    # ### end Alembic commands ###
