"""
Alembic migration script template
add_custom_prompts_table

Revision ID: 5206607942a2
Revises: cb71a958ad92
Create Date: 2026-02-22 20:07:33.224269
"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


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


def upgrade() -> None:
    op.create_table(
        "custom_prompts",
        sa.Column("id", sa.String(length=36), nullable=False),
        sa.Column("user_id", sa.String(length=36), nullable=False),
        sa.Column("name", sa.String(length=255), nullable=False),
        sa.Column("content", sa.Text(), nullable=False),
        sa.Column("created_at", sa.DateTime(), nullable=True),
        sa.Column("updated_at", sa.DateTime(), nullable=True),
        sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        "ix_custom_prompts_user_id", "custom_prompts", ["user_id"], unique=False
    )


def downgrade() -> None:
    op.drop_index("ix_custom_prompts_user_id", table_name="custom_prompts")
    op.drop_table("custom_prompts")
