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.
pull/400/head
Mike Lang 4 months ago committed by Mike Lang
parent e9281e652c
commit 115fd8bba3

@ -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
);

Loading…
Cancel
Save