"""Add group_key column to articles for cross-language static article grouping.

Static cornerstone articles (e.g. padel-hall-cost-guide EN vs padel-halle-kosten DE)
have different url_paths per language, so they cannot be grouped by url_path alone.
The group_key (populated from the `cornerstone` frontmatter field, e.g. 'C2') is a
shared key that pairs EN/DE variants of the same static article.

pSEO articles leave group_key NULL and continue to group by url_path (unchanged).

Also removes any state-of-padel articles that are being moved to the reports flow.
"""


def up(conn):
    conn.execute(
        "ALTER TABLE articles ADD COLUMN group_key TEXT DEFAULT NULL"
    )
    conn.execute(
        "CREATE INDEX IF NOT EXISTS idx_articles_group_key"
        " ON articles(group_key)"
    )
    # Remove state-of-padel rows — these are moving to the reports flow
    # and would cause slug collisions (both EN/DE use slug 'state-of-padel-q1-2026')
    conn.execute("DELETE FROM articles WHERE slug LIKE 'state-of-padel%'")
