fp/services/migrations-schema/migrations/00077_builds-trigger-change...

23 lines
544 B
MySQL
Raw Normal View History

2024-10-02 17:38:24 +00:00
-- we've renamed api.builds.vod to api.builds.vod_id
DROP FUNCTION public.tg__add_build_job CASCADE;
CREATE FUNCTION public.tg__add_build_job() RETURNS trigger
LANGUAGE plpgsql SECURITY DEFINER
SET search_path TO 'pg_catalog', 'public', 'pg_temp'
AS $$
begin
PERFORM graphile_worker.add_job(NEW.task, json_build_object(
'vod_id', NEW.vod_id
), max_attempts := 6);
return NEW;
end;
$$;
CREATE TRIGGER create_build
AFTER UPDATE ON api.builds
FOR EACH ROW
EXECUTE FUNCTION tg__add_build_job();