"""add certificate template selection

Revision ID: 20260813_0007
Revises: 20260813_0006
Create Date: 2026-08-13
"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa

revision: str = "20260813_0007"
down_revision: Union[str, None] = "20260813_0006"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.add_column(
        "project_courses",
        sa.Column("default_template_code", sa.String(length=32), nullable=False, server_default="classic"),
    )
    op.add_column(
        "certificates",
        sa.Column("template_code", sa.String(length=32), nullable=False, server_default="classic"),
    )
    op.create_index("ix_certificates_template_code", "certificates", ["template_code"])
    op.add_column(
        "import_batches",
        sa.Column("template_code", sa.String(length=32), nullable=False, server_default="classic"),
    )


def downgrade() -> None:
    op.drop_column("import_batches", "template_code")
    op.drop_index("ix_certificates_template_code", table_name="certificates")
    op.drop_column("certificates", "template_code")
    op.drop_column("project_courses", "default_template_code")
