From 115fd8bba37826d6f73dc8a9d1b7927d90db026d Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Fri, 2 Aug 2024 21:29:30 +0000 Subject: [PATCH] schema: Add first and last event ids to playlist table These represent a pinned first/last video in a playlist. On the choice of a video id vs an event id: - Event ids are known before video ids, so we can "set and forget" before a video is uploaded - No need to re-set if an event's video is re-edited or changed - In cases where an external video is desired, we can use manual link to associate an event with it Since we're referencing a primary key, we might as well also make it a proper foreign key with sensible delete behaviour, though in practice we never delete events. --- postgres/setup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/postgres/setup.sh b/postgres/setup.sh index eaa9fab..22bbca3 100644 --- a/postgres/setup.sh +++ b/postgres/setup.sh @@ -147,6 +147,8 @@ CREATE TABLE playlists ( playlist_id TEXT PRIMARY KEY, name TEXT NOT NULL, tags TEXT[] NOT NULL, + first_event_id UUID REFERENCES events(id) ON DELETE SET NULL, + last_event_id UUID REFERENCES events(id) ON DELETE SET NULL, show_in_description BOOLEAN NOT NULL );