"""Add the running discussion list, seeded with the open questions so far

Revision ID: f6a7b8c9d0e1
Revises: e5f6a7b8c9d0
"""
from collections.abc import Sequence

import sqlalchemy as sa
from alembic import op

revision: str = "f6a7b8c9d0e1"
down_revision: str | None = "e5f6a7b8c9d0"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None

# Headline plus a few words. Kept terse on purpose: this is a talking list,
# not a document.
SEED = [
    ("Product images", "Ask brands to supply official shots. Placeholders are open-licensed.", 10),
    ("Categories beyond spirits", "Fragrance, beauty, tobacco, confectionery -- in scope or later?", 20),
    ("Airports for Cannes", "Which 10-50 matter most for outreach?", 30),
    ("Refresh frequency", "Daily or weekly. Drives the running cost.", 40),
    ("Shops that block us", "Avolta and others. Ask for data access rather than scraping?", 50),
    ("Heinemann per-airport prices", "Their robots blocks it. Worth a direct ask.", 60),
    ("Where content is written", "Keep WordPress for Kristine and Matt, or move?", 70),
    ("Price alerts and accounts", "Needed for launch, or later?", 80),
    ("Duty Free Awards medals", "Slots in automatically once the first competition runs.", 90),
    ("Legal review before launch", "Half an hour with a lawyer. Not needed for the demo.", 100),
]


def upgrade() -> None:
    table = op.create_table(
        "discussion_items",
        sa.Column("id", sa.Integer(), primary_key=True),
        sa.Column("title", sa.String(120), nullable=False),
        sa.Column("note", sa.String(240), nullable=True),
        sa.Column("resolved", sa.Boolean(), nullable=False, server_default=sa.false()),
        sa.Column("sort_order", sa.Integer(), nullable=False, server_default="100"),
        sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
        sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
    )
    op.bulk_insert(
        table,
        [{"title": t, "note": n, "resolved": False, "sort_order": o} for t, n, o in SEED],
    )


def downgrade() -> None:
    op.drop_table("discussion_items")
