Files
archie/internal/infrastructure/postgres/migrations/0064_schedule_fired.sql
T

25 lines
1.2 KiB
SQL

-- A schedule's firing is captured on the reserved "schedule" source. This
-- built-in event type identifies every capture there, and the built-in mapping
-- hands a binding the firing's fields, so a schedule trigger is an ordinary
-- binding on that source filtered to one schedule_id.
-- +goose Up
INSERT INTO event_types (id, source, name, rule, schema, org_id, workspace_id)
VALUES ('schedule-fired', 'schedule', 'Schedule fired', '{"headers":[],"payload":[]}',
'{"schedule_id":"string","name":"string","scheduled_for":"string","fired_at":"string"}',
'org-sys', 'default')
ON CONFLICT (id) DO NOTHING;
INSERT INTO mappings (id, name, source_hint, event_type, fields, org_id, workspace_id)
VALUES ('schedule-fired', 'Schedule fired', 'schedule', 'schedule-fired',
'[{"name":"schedule_id","path":"schedule_id","type":"string","required":true},'
'{"name":"name","path":"name","type":"string","required":false},'
'{"name":"scheduled_for","path":"scheduled_for","type":"string","required":true},'
'{"name":"fired_at","path":"fired_at","type":"string","required":true}]',
'org-sys', 'default')
ON CONFLICT (id) DO NOTHING;
-- +goose Down
DELETE FROM mappings WHERE id = 'schedule-fired';
DELETE FROM event_types WHERE id = 'schedule-fired';