Files
thamanyah/discovery/internal/db/migrations/0002_create_videos_table.up.sql
T
FahdShalhoub 6f9e04ee97
Build, Push and Deploy CMS / build-push-deploy (push) Successful in 2m35s
Build, Push and Deploy Discovery / build-push-deploy (push) Successful in 1m55s
Deploy Infrastructure / pulumi-up (push) Successful in 2s
FEAT: Discovery Video Service Subscription
2026-08-29 16:50:58 +03:00

20 lines
976 B
SQL

-- The catalogue's own copy of a video, built from the announcements cms
-- publishes on the catalogue topic. It is a read model, not a second source of
-- truth: every column here arrives in an announcement, and nothing in this
-- service ever writes a video of its own.
--
-- id is the id cms issued, carried in the announcement and reused verbatim, so
-- the two services can talk about the same video without a mapping table. It
-- is therefore NOT generated here: no DEFAULT, unlike cms's videos.id.
CREATE TABLE videos (
id UUID PRIMARY KEY,
title TEXT NOT NULL,
playback_url TEXT NOT NULL DEFAULT '',
-- Denormalized on purpose. cms owns the category vocabulary and sends
-- names, so there is nothing here to join to and no id to keep in step;
-- an array is what the read side actually serves.
categories TEXT[] NOT NULL DEFAULT '{}',
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);