"""trending Revision ID: 0003_trending Revises: 0002_watch_providers Create Date: 2026-09-06 Adds trending_entries (section 17, additive): Aurora's mirror of TMDb's own trending lists, refreshed on a schedule -- see app/services/ingestion/trending_ingestion.py. """ from __future__ import annotations from collections.abc import Sequence import sqlalchemy as sa from alembic import op revision: str = "0003_trending" down_revision: str | None = "0002_watch_providers" branch_labels: str | Sequence[str] | None = None depends_on: str | Sequence[str] | None = None def upgrade() -> None: op.create_table( "trending_entries", sa.Column("id", sa.Uuid(), primary_key=True), sa.Column( "created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False, ), sa.Column( "updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False, ), sa.Column("entity_type", sa.String(30), nullable=False), sa.Column("entity_id", sa.Uuid(), nullable=False), sa.Column("time_window", sa.String(10), nullable=False), sa.Column("rank", sa.Integer(), nullable=False), ) op.create_index("ix_trending_entries_entity_id", "trending_entries", ["entity_id"]) op.create_index( "ix_trending_entries_window", "trending_entries", ["entity_type", "time_window"] ) def downgrade() -> None: op.drop_index("ix_trending_entries_window", table_name="trending_entries") op.drop_index("ix_trending_entries_entity_id", table_name="trending_entries") op.drop_table("trending_entries")