20 lines
976 B
SQL
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()
|
|
);
|