"""workflow copilot chat

Revision ID: db8667f8ce63
Revises: e393f33ec711
Create Date: 2026-01-06 21:48:28.396490+00:00

"""

from typing import Sequence, Union

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "db8667f8ce63"
down_revision: Union[str, None] = "e393f33ec711"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "workflow_copilot_chat_messages",
        sa.Column("workflow_copilot_chat_message_id", sa.String(), nullable=False),
        sa.Column("workflow_copilot_chat_id", sa.String(), nullable=False),
        sa.Column("organization_id", sa.String(), nullable=False),
        sa.Column("sender", sa.String(), nullable=False),
        sa.Column("content", sa.UnicodeText(), nullable=False),
        sa.Column("global_llm_context", sa.UnicodeText(), nullable=True),
        sa.Column("created_at", sa.DateTime(), nullable=False),
        sa.Column("modified_at", sa.DateTime(), nullable=False),
        sa.PrimaryKeyConstraint("workflow_copilot_chat_message_id"),
    )
    op.create_index(
        op.f("ix_workflow_copilot_chat_messages_workflow_copilot_chat_id"),
        "workflow_copilot_chat_messages",
        ["workflow_copilot_chat_id"],
        unique=False,
    )
    op.create_table(
        "workflow_copilot_chats",
        sa.Column("workflow_copilot_chat_id", sa.String(), nullable=False),
        sa.Column("organization_id", sa.String(), nullable=False),
        sa.Column("workflow_permanent_id", sa.String(), nullable=False),
        sa.Column("created_at", sa.DateTime(), nullable=False),
        sa.Column("modified_at", sa.DateTime(), nullable=False),
        sa.PrimaryKeyConstraint("workflow_copilot_chat_id"),
    )
    op.create_index(
        op.f("ix_workflow_copilot_chats_workflow_permanent_id"),
        "workflow_copilot_chats",
        ["workflow_permanent_id"],
        unique=False,
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f("ix_workflow_copilot_chats_workflow_permanent_id"), table_name="workflow_copilot_chats")
    op.drop_table("workflow_copilot_chats")
    op.drop_index(
        op.f("ix_workflow_copilot_chat_messages_workflow_copilot_chat_id"), table_name="workflow_copilot_chat_messages"
    )
    op.drop_table("workflow_copilot_chat_messages")
    # ### end Alembic commands ###
