fp/services/migrations-schema/migrations/00054_remove-bytes-from-vod...

28 lines
693 B
PL/PgSQL

DROP FUNCTION update_vod_on_segment_update CASCADE;
-- 'NEW' in this context is a segment row.
-- we re-create this trigger function, but this time make it's name more consistent with others
-- we also remove the conditional status column because it relies on the non-existant bytes column
CREATE OR REPLACE FUNCTION tg__update_vod_updated_at()
RETURNS TRIGGER AS $$
BEGIN
UPDATE api.vods
SET
updated_at = NOW()
WHERE id IN (
SELECT vod_id
FROM segments_vod_links
WHERE segment_id = NEW.id
);
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER trigger_update_vod
AFTER UPDATE ON api.segments
FOR EACH ROW
EXECUTE FUNCTION tg__update_vod_updated_at();