Skip to content

Commit

Permalink
Add cascade delete to kv store table fk
Browse files Browse the repository at this point in the history
  • Loading branch information
ilija42 committed Mar 28, 2024
1 parent ffd4922 commit 5c724be
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
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 5c724be

Please sign in to comment.