19 lines
431 B
PL/PgSQL
19 lines
431 B
PL/PgSQL
-- we want this function to set the vod status to recording
|
|
CREATE OR REPLACE FUNCTION tg__update_vod_updated_at()
|
|
RETURNS TRIGGER AS $$
|
|
BEGIN
|
|
UPDATE api.vods
|
|
SET
|
|
updated_at = NOW(),
|
|
status = CASE
|
|
WHEN NEW.filesize > OLD.filesize THEN 'recording'
|
|
ELSE status
|
|
END
|
|
WHERE id IN (
|
|
SELECT vod_id
|
|
FROM segments_vod_links
|
|
WHERE segment_id = NEW.id
|
|
);
|
|
RETURN NEW;
|
|
END;
|
|
$$ LANGUAGE plpgsql; |