"""drop legacy external overlay type

Revision ID: 0004_drop_legacy_external_overlay_type
Revises: 0003_global_map_overlays
Create Date: 2026-05-08
"""
from typing import Sequence, Union

from alembic import op


revision: str = "0004_drop_legacy_external_overlay_type"
down_revision: Union[str, Sequence[str], None] = "0003_global_map_overlays"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.execute(
        "DELETE FROM jobs "
        "WHERE overlay_id IN (SELECT id FROM overlays WHERE type = 'external')"
    )
    op.execute(
        "DELETE FROM blueprint_overlays "
        "WHERE overlay_id IN (SELECT id FROM overlays WHERE type = 'external')"
    )
    op.execute("DELETE FROM overlays WHERE type = 'external'")


def downgrade() -> None:
    # data is gone; intentional one-way migration
    pass
