"""drop RSS infrastructure (tables + leftover briefing settings)

Revision ID: 0042
Revises: 0041
Create Date: 2026-04-26

Hard-cut removal of the RSS feature. Drops rss_feeds, rss_items,
rss_item_reactions, rss_item_embeddings, and clears the leftover
briefing-era settings rows that referenced RSS topic preferences.
"""
from alembic import op


revision = "0042"
down_revision = "0041"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # Drop in dependency order — children first.
    op.execute("DROP TABLE IF EXISTS rss_item_embeddings CASCADE")
    op.execute("DROP TABLE IF EXISTS rss_item_reactions CASCADE")
    op.execute("DROP TABLE IF EXISTS rss_items CASCADE")
    op.execute("DROP TABLE IF EXISTS rss_feeds CASCADE")
    op.execute(
        "DELETE FROM settings WHERE key IN "
        "('rss_enabled', 'briefing_include_topics', 'briefing_exclude_topics')"
    )


def downgrade() -> None:
    # No downgrade — this is a destructive cleanup. The original RSS tables
    # would have to be recreated by replaying migrations 0026, 0028, 0035,
    # 0038, 0039 manually (and the data would not come back).
    raise NotImplementedError("RSS feature is permanently removed in 0042")
