"""favorite_movies — single-user favorites + last_seen_at dla NEW badge.

Revision ID: 0014_favorite_movies
Revises: 0013_bug_reports
Create Date: 2026-05-09

Mirror `favorite_studios` z movie_id zamiast studio_id. NEW badge w mobile
liczone client-side: movie.created_at > favorite.last_seen_at.
"""
from collections.abc import Sequence

import sqlalchemy as sa
from alembic import op

revision: str = "0014_favorite_movies"
down_revision: str | None = "0013_bug_reports"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    op.create_table(
        "favorite_movies",
        sa.Column(
            "movie_id",
            sa.dialects.postgresql.UUID(as_uuid=True),
            sa.ForeignKey("movies.id", ondelete="CASCADE"),
            primary_key=True,
        ),
        sa.Column(
            "created_at",
            sa.DateTime(timezone=True),
            server_default=sa.func.now(),
            nullable=False,
        ),
        sa.Column(
            "last_seen_at",
            sa.DateTime(timezone=True),
            server_default=sa.func.now(),
            nullable=False,
        ),
    )


def downgrade() -> None:
    op.drop_table("favorite_movies")
