proper sql filtering

This commit is contained in:
2026-03-01 20:43:48 -06:00
parent 6b9d7d6cf2
commit bbe94d75f8
54 changed files with 6692 additions and 928 deletions

View File

@@ -28,6 +28,7 @@ CREATE TABLE execution (
executor BIGINT, -- references identity(id); no FK because execution becomes a hypertable
status execution_status_enum NOT NULL DEFAULT 'requested',
result JSONB,
started_at TIMESTAMPTZ, -- set when execution transitions to 'running'
created TIMESTAMPTZ NOT NULL DEFAULT NOW(),
is_workflow BOOLEAN DEFAULT false NOT NULL,
workflow_def BIGINT, -- references workflow_definition(id); no FK because execution becomes a hypertable

View File

@@ -34,6 +34,7 @@ BEGIN
'trigger_ref', enforcement_trigger_ref,
'parent', NEW.parent,
'result', NEW.result,
'started_at', NEW.started_at,
'created', NEW.created,
'updated', NEW.updated
);
@@ -75,6 +76,7 @@ BEGIN
'trigger_ref', enforcement_trigger_ref,
'parent', NEW.parent,
'result', NEW.result,
'started_at', NEW.started_at,
'created', NEW.created,
'updated', NEW.updated
);

View File

@@ -196,7 +196,7 @@ COMMENT ON TABLE execution IS 'Executions represent action runs with workflow su
-- ----------------------------------------------------------------------------
-- execution history trigger
-- Tracked fields: status, result, executor, workflow_task, env_vars
-- Tracked fields: status, result, executor, workflow_task, env_vars, started_at
-- Note: result uses _jsonb_digest_summary() to avoid storing large payloads
-- ----------------------------------------------------------------------------
@@ -215,7 +215,8 @@ BEGIN
'action_ref', NEW.action_ref,
'executor', NEW.executor,
'parent', NEW.parent,
'enforcement', NEW.enforcement
'enforcement', NEW.enforcement,
'started_at', NEW.started_at
));
RETURN NEW;
END IF;
@@ -260,6 +261,12 @@ BEGIN
new_vals := new_vals || jsonb_build_object('env_vars', NEW.env_vars);
END IF;
IF OLD.started_at IS DISTINCT FROM NEW.started_at THEN
changed := array_append(changed, 'started_at');
old_vals := old_vals || jsonb_build_object('started_at', OLD.started_at);
new_vals := new_vals || jsonb_build_object('started_at', NEW.started_at);
END IF;
-- Only record if something actually changed
IF array_length(changed, 1) > 0 THEN
INSERT INTO execution_history (time, operation, entity_id, entity_ref, changed_fields, old_values, new_values)