- FastAPI + PostgreSQL + Alembic + React/Vite skeleton, Docker Compose, healthcheck - Google OAuth (single allowed account), encrypted refresh token storage - Subscriptions sync with pagination, uploads playlist batch fetch - Categories CRUD, many-to-many channel assignment, category filtering - Video sync (playlistItems + videos.list batching), cached feed with cursor pagination, background scheduler (APScheduler) - Video detail page with YouTube embed player - SPA fallback routing, optimistic UI updates, client-side query caching 40 backend tests covering OAuth allow-list, sync idempotency, cascade deletes, cursor pagination, and category filtering. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
50 lines
2.2 KiB
Python
50 lines
2.2 KiB
Python
"""oauth_credentials and channels
|
|
|
|
Revision ID: 0002_oauth_channels
|
|
Revises: 0001_app_settings
|
|
Create Date: 2026-09-16
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
revision: str = "0002_oauth_channels"
|
|
down_revision: Union[str, None] = "0001_app_settings"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"oauth_credentials",
|
|
sa.Column("id", sa.Integer(), primary_key=True),
|
|
sa.Column("google_email", sa.String(length=255), nullable=False),
|
|
sa.Column("encrypted_refresh_token", sa.String(), nullable=False),
|
|
sa.Column("access_token_expires_at", sa.DateTime(timezone=True), nullable=True),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
)
|
|
|
|
op.create_table(
|
|
"channels",
|
|
sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True),
|
|
sa.Column("youtube_channel_id", sa.String(length=64), nullable=False),
|
|
sa.Column("title", sa.String(length=255), nullable=False),
|
|
sa.Column("description", sa.Text(), nullable=True),
|
|
sa.Column("thumbnail_url", sa.String(), nullable=True),
|
|
sa.Column("uploads_playlist_id", sa.String(length=64), nullable=True),
|
|
sa.Column("subscribed", sa.Boolean(), nullable=False, server_default=sa.true()),
|
|
sa.Column("last_synced_at", sa.DateTime(timezone=True), nullable=True),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
sa.UniqueConstraint("youtube_channel_id", name="uq_channels_youtube_channel_id"),
|
|
)
|
|
op.create_index("ix_channels_youtube_channel_id", "channels", ["youtube_channel_id"])
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_channels_youtube_channel_id", table_name="channels")
|
|
op.drop_table("channels")
|
|
op.drop_table("oauth_credentials")
|