-- Bobinoo — 29 nov. 2026 : notes Trakt gardées côté serveur (pour tout le monde). Idempotent. -- La fonction serveur « ratings » lit ici avant d'interroger Trakt : une fiche déjà vue dans la journée -- (par n'importe qui) a sa note tout de suite. La correspondance TMDB → Trakt, elle, ne change jamais. -- Données publiques (notes du public Trakt) ; seule la fonction serveur y accède (clé de service) : aucune règle d'accès. create table if not exists public.title_ratings ( external_id text primary key check (external_id ~ '^tmdb:(movie|tv):[0-9]{1,10}$'), trakt_id integer, found boolean not null default true, rating numeric(4, 2), votes integer not null default 0 check (votes >= 0), distribution jsonb, fetched_at timestamptz not null default now() ); alter table public.title_ratings enable row level security; revoke all on public.title_ratings from public, anon, authenticated;