"""Add project titles.

Revision ID: 003
Revises: 002
Create Date: 2026-06-24
"""

from typing import Sequence, Union

import sqlalchemy as sa

from alembic import op

revision: str = "003"
down_revision: Union[str, None] = "002"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.create_table(
        "project_titles",
        sa.Column("id", sa.String(length=36), nullable=False),
        sa.Column("workspace_id", sa.String(length=36), nullable=False),
        sa.Column("project_id", sa.String(length=36), nullable=False),
        sa.Column("text", sa.String(length=200), nullable=False),
        sa.Column("category", sa.String(length=50), nullable=False, server_default="default"),
        sa.Column("usage_count", sa.Integer(), nullable=False, server_default="0"),
        sa.Column("is_active", sa.Boolean(), nullable=False, server_default=sa.true()),
        sa.Column("created_by_user_id", sa.String(length=36), nullable=False),
        sa.Column("created_at", sa.DateTime(), nullable=False),
        sa.Column("updated_at", sa.DateTime(), nullable=False),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(op.f("ix_project_titles_project_id"), "project_titles", ["project_id"], unique=False)
    op.create_index(op.f("ix_project_titles_workspace_id"), "project_titles", ["workspace_id"], unique=False)
    op.create_index(op.f("ix_project_titles_category"), "project_titles", ["category"], unique=False)


def downgrade() -> None:
    op.drop_index(op.f("ix_project_titles_category"), table_name="project_titles")
    op.drop_index(op.f("ix_project_titles_workspace_id"), table_name="project_titles")
    op.drop_index(op.f("ix_project_titles_project_id"), table_name="project_titles")
    op.drop_table("project_titles")
