-- create s3_files table CREATE TABLE api.s3_files ( id uuid PRIMARY KEY DEFAULT gen_random_uuid(), s3_id TEXT NOT NULL, s3_key TEXT NOT NULL, bucket TEXT NOT NULL ); GRANT all ON api.vods TO automation; GRANT SELECT ON api.vods TO web_anon; -- create mux_assets table CREATE TABLE api.mux_assets ( id uuid PRIMARY KEY DEFAULT gen_random_uuid(), asset_id TEXT NOT NULL, playback_id TEXT NOT NULL, created_at TIMESTAMP DEFAULT NOW(), updated_at TIMESTAMP DEFAULT NOW() ); GRANT all ON api.mux_assets TO automation; -- web_anon is intentionally not given privs to this table -- re-create vods table DROP TABLE api.vods CASCADE; CREATE TABLE api.vods ( id uuid PRIMARY KEY DEFAULT gen_random_uuid(), stream_id UUID NOT NULL REFERENCES api.streams(id), created_at TIMESTAMP DEFAULT NOW(), updated_at TIMESTAMP DEFAULT NOW(), published_at DATE, title TEXT, date DATE NOT NULL, mux_asset UUID REFERENCES api.mux_assets(id), thumbnail UUID REFERENCES api.s3_files(id), vtuber UUID REFERENCES api.vtubers(id), ipfs_cid TEXT, s3_file UUID REFERENCES api.s3_files(id), torrent TEXT, announce_title TEXT, announce_url TEXT, note TEXT ); GRANT all ON api.vods TO automation; GRANT SELECT ON api.vods TO web_anon;