"""drop realdebrid_cache table — RD nie wykorzystywany (Hetzner IP blocked)

Revision ID: 0017_drop_realdebrid_cache
Revises: 0016_realdebrid_cache
Create Date: 2026-05-12

Real-Debrid integration cofnięta — Hetzner VPS IP blokowany globalnie przez
RD anti-abuse, a 95% relevantnych hosterów (streamtape/playmogo/dood/mixdrop/
filemoon/iceyfile) są DOWN lub UNSUPPORTED w RD list. Tylko voe.sx + file
hosters UP, nie pokrywa naszego streaming use case.
"""
from collections.abc import Sequence

import sqlalchemy as sa
from alembic import op

revision: str = "0017_drop_realdebrid_cache"
down_revision: str | None = "0016_realdebrid_cache"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    op.drop_index("ix_realdebrid_cache_expires_at", table_name="realdebrid_cache")
    op.drop_table("realdebrid_cache")


def downgrade() -> None:
    op.create_table(
        "realdebrid_cache",
        sa.Column("hoster_url", sa.Text(), primary_key=True),
        sa.Column("direct_url", sa.Text(), nullable=False),
        sa.Column("created_at", sa.TIMESTAMP(timezone=True), nullable=False,
                  server_default=sa.text("now()")),
        sa.Column("expires_at", sa.TIMESTAMP(timezone=True), nullable=False),
    )
    op.create_index("ix_realdebrid_cache_expires_at", "realdebrid_cache", ["expires_at"])
