"""bug_reports — in-app bug reporting (mobile FAB → POST /bug-reports)

Revision ID: 0013_bug_reports
Revises: 0012_favorite_studios
Create Date: 2026-05-09

User wpisuje opis + appka kapturuje screen (react-native-view-shot omija
FLAG_SECURE) → wysyła POST. Backend trzyma w tabeli, admin_html ma listę.
"""
from collections.abc import Sequence

import sqlalchemy as sa
from alembic import op

revision: str = "0013_bug_reports"
down_revision: str | None = "0012_favorite_studios"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    op.create_table(
        "bug_reports",
        sa.Column(
            "id",
            sa.dialects.postgresql.UUID(as_uuid=True),
            primary_key=True,
        ),
        sa.Column(
            "created_at",
            sa.DateTime(timezone=True),
            server_default=sa.func.now(),
            nullable=False,
        ),
        sa.Column("screen_name", sa.String(64), nullable=True),
        sa.Column("app_version", sa.String(32), nullable=True),
        sa.Column(
            "scene_id",
            sa.dialects.postgresql.UUID(as_uuid=True),
            sa.ForeignKey("scenes.id", ondelete="SET NULL"),
            nullable=True,
        ),
        sa.Column("message", sa.Text, nullable=False),
        sa.Column("screenshot_b64", sa.Text, nullable=True),
        sa.Column("resolved", sa.Boolean, nullable=False, server_default=sa.false()),
    )
    op.create_index("ix_bug_reports_created_at", "bug_reports", ["created_at"])


def downgrade() -> None:
    op.drop_index("ix_bug_reports_created_at", table_name="bug_reports")
    op.drop_table("bug_reports")
