-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cascade delete to kv store table fk
- Loading branch information
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
core/store/migrate/migrations/0229_add_kv_store_job_fk_cascade_delete.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |