"""Add collection landing page metadata.

Revision ID: 0043_add_collection_landing_page
Revises: 0042_add_channel_pipeline_readiness_cache
Create Date: 2026-06-18 14:45:00.000000
"""

from __future__ import annotations

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

revision = "0043_add_collection_landing_page"
down_revision = "0042_add_channel_pipeline_readiness_cache"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.create_table(
        "collection_landing_page",
        sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True),
        sa.Column("path_slug", sa.String(512), nullable=False),
        sa.Column("page_type", sa.String(32), nullable=False, server_default="collection"),
        sa.Column("category_l1", sa.Text(), nullable=True),
        sa.Column("collection", sa.Text(), nullable=True),
        sa.Column("brand", sa.Text(), nullable=True),
        sa.Column("title", sa.Text(), nullable=False),
        sa.Column("subtitle", sa.Text(), nullable=True),
        sa.Column("short_description", sa.Text(), nullable=True),
        sa.Column("description_html", sa.Text(), nullable=True),
        sa.Column("specifications_html", sa.Text(), nullable=True),
        sa.Column("materials_html", sa.Text(), nullable=True),
        sa.Column("assembly_html", sa.Text(), nullable=True),
        sa.Column("pdf_url", sa.Text(), nullable=True),
        sa.Column("thumbnail_image_url", sa.Text(), nullable=True),
        sa.Column("hero_images", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("badges", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("feature_bullets", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("cta_rows", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("matching_collection_slugs", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("starting_price", sa.Numeric(12, 4), nullable=True),
        sa.Column("sort_order", sa.Integer(), nullable=False, server_default="100"),
        sa.Column("is_active", sa.Boolean(), nullable=False, server_default=sa.text("true")),
        sa.Column("notes", sa.Text(), nullable=True),
        sa.Column(
            "updated_at",
            sa.DateTime(timezone=True),
            nullable=False,
            server_default=sa.text("now()"),
        ),
        sa.UniqueConstraint("path_slug", name="uq_collection_landing_page_path_slug"),
    )
    op.create_index("ix_collection_landing_page_path_slug", "collection_landing_page", ["path_slug"])
    op.create_index("ix_collection_landing_page_page_type", "collection_landing_page", ["page_type"])
    op.create_index("ix_collection_landing_page_category_l1", "collection_landing_page", ["category_l1"])
    op.create_index("ix_collection_landing_page_collection", "collection_landing_page", ["collection"])


def downgrade() -> None:
    op.drop_index("ix_collection_landing_page_collection", table_name="collection_landing_page")
    op.drop_index("ix_collection_landing_page_category_l1", table_name="collection_landing_page")
    op.drop_index("ix_collection_landing_page_page_type", table_name="collection_landing_page")
    op.drop_index("ix_collection_landing_page_path_slug", table_name="collection_landing_page")
    op.drop_table("collection_landing_page")
