From 143741012c4d0b148ada9d5aa237ff932cd3005b Mon Sep 17 00:00:00 2001 From: Cedric Date: Thu, 23 May 2024 02:37:00 +0100 Subject: [PATCH] Add ON DELETE CASCADE to workflow tables (#13165) --- .changeset/tame-mice-give.md | 5 +++ ...0237_add_workflow_executions_on_delete.sql | 31 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .changeset/tame-mice-give.md create mode 100644 core/store/migrate/migrations/0237_add_workflow_executions_on_delete.sql diff --git a/.changeset/tame-mice-give.md b/.changeset/tame-mice-give.md new file mode 100644 index 00000000000..7cd59b154ad --- /dev/null +++ b/.changeset/tame-mice-give.md @@ -0,0 +1,5 @@ +--- +"chainlink": patch +--- + +#db_update Add ON DELETE CASCADE to workflow tables diff --git a/core/store/migrate/migrations/0237_add_workflow_executions_on_delete.sql b/core/store/migrate/migrations/0237_add_workflow_executions_on_delete.sql new file mode 100644 index 00000000000..87670d0ab61 --- /dev/null +++ b/core/store/migrate/migrations/0237_add_workflow_executions_on_delete.sql @@ -0,0 +1,31 @@ +-- +goose Up +-- +goose StatementBegin +ALTER TABLE workflow_executions +DROP CONSTRAINT workflow_executions_workflow_id_fkey, +ADD CONSTRAINT workflow_executions_workflow_id_fkey + FOREIGN KEY (workflow_id) + REFERENCES workflow_specs(workflow_id) + ON DELETE CASCADE; + +ALTER TABLE workflow_steps +DROP CONSTRAINT workflow_steps_workflow_execution_id_fkey, +ADD CONSTRAINT workflow_steps_workflow_execution_id_fkey + FOREIGN KEY (workflow_execution_id) + REFERENCES workflow_executions(id) + ON DELETE CASCADE; +-- +goose StatementEnd + +-- +goose Down +-- +goose StatementBegin +ALTER TABLE workflow_executions +DROP CONSTRAINT workflow_executions_workflow_id_fkey, +ADD CONSTRAINT workflow_executions_workflow_id_fkey + FOREIGN KEY (workflow_id) + REFERENCES workflow_specs(workflow_id); + +ALTER TABLE workflow_steps +DROP CONSTRAINT workflow_steps_workflow_execution_id_fkey, +ADD CONSTRAINT workflow_steps_workflow_execution_id_fkey + FOREIGN KEY (workflow_execution_id) + REFERENCES workflow_executions(id); +-- +goose StatementEnd