Files
sam c30624a59e
Quality / check (push) Successful in 4m12s
deploy / gate (push) Successful in 4m42s
deploy / archied-image (push) Successful in 3m13s
deploy / agent-image (push) Successful in 11s
deploy / dist-zip (push) Skipped
feat(workflow): a handoff starts a separate linked run of the next workflow (#1791)
2026-11-03 20:56:03 +11:00

18 lines
901 B
SQL

-- +goose Up
-- A workflow.handoff ends its run and starts a linked run of the next workflow
-- on the same work item. Only the current run of an item is unique; a run
-- that handed off points at its successor and leaves the key.
ALTER TABLE tasks
ADD COLUMN handoff_from_task_id bigint REFERENCES tasks (id) ON DELETE SET NULL,
ADD COLUMN handoff_to_task_id bigint;
ALTER TABLE tasks DROP CONSTRAINT tasks_org_identity_owner_repo_number_key;
CREATE UNIQUE INDEX tasks_current_item_key ON tasks (org_id, identity, owner, repo, issue_number)
WHERE handoff_to_task_id IS NULL;
-- +goose Down
DELETE FROM tasks WHERE handoff_to_task_id IS NOT NULL;
DROP INDEX tasks_current_item_key;
ALTER TABLE tasks ADD CONSTRAINT tasks_org_identity_owner_repo_number_key
UNIQUE (org_id, identity, owner, repo, issue_number);
ALTER TABLE tasks DROP COLUMN handoff_to_task_id, DROP COLUMN handoff_from_task_id;