Skip to content

Commit

Permalink
Merge pull request #12631 from smartcontractkit/chore/release/2.10.0-…
Browse files Browse the repository at this point in the history
…cherry-pick-1

Add cascade delete to kv store table fk (cherry pick)
  • Loading branch information
chainchad authored Mar 28, 2024
2 parents 47eb373 + 37e2532 commit 513983a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/brave-games-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": major
---

Fix kv_store migration fk cascade deletion
2 changes: 2 additions & 0 deletions core/services/job/kv_orm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,6 @@ func TestJobKVStore(t *testing.T) {
require.NoError(t, kvStore.Store(key, td2))
require.NoError(t, kvStore.Get(key, &retData))
require.Equal(t, td2, retData)

require.NoError(t, jobORM.DeleteJob(jobID))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-- +goose Up

BEGIN;

ALTER TABLE job_kv_store DROP CONSTRAINT job_kv_store_job_id_fkey;
ALTER TABLE job_kv_store
ADD CONSTRAINT job_kv_store_job_id_fkey
FOREIGN KEY (job_id)
REFERENCES jobs(id)
ON DELETE CASCADE;

COMMIT;

-- +goose Down
BEGIN;

ALTER TABLE job_kv_store DROP CONSTRAINT job_kv_store_job_id_fkey;
ALTER TABLE job_kv_store
ADD CONSTRAINT job_kv_store_job_id_fkey
FOREIGN KEY (job_id)
REFERENCES jobs(id);

COMMIT;

0 comments on commit 513983a

Please sign in to comment.