"""Production agencies: add Rapp, remove Mindshare and Zenith

Revision ID: 009_production_agencies
Revises: 008_add_user_change_log
Create Date: 2026-03-06

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa

revision: str = '009_production_agencies'
down_revision: Union[str, None] = '008_add_user_change_log'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # Remove agencies not used in production
    op.execute("DELETE FROM agencies WHERE name IN ('Mindshare', 'Zenith')")
    # Add Rapp (idempotent)
    op.execute("INSERT INTO agencies (name) VALUES ('Rapp') ON CONFLICT (name) DO NOTHING")


def downgrade() -> None:
    op.execute("DELETE FROM agencies WHERE name = 'Rapp'")
    op.execute("INSERT INTO agencies (name) VALUES ('Mindshare') ON CONFLICT (name) DO NOTHING")
    op.execute("INSERT INTO agencies (name) VALUES ('Zenith') ON CONFLICT (name) DO NOTHING")
