-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
db/migrations: adds constraint on firmware sets to restrict fimrmware…
… deletion When a firmware row is referenced by a firmware set, restrict deletion of the firmware row, This ensures referential integrity in firmware sets. Updates test for constraint check.
- Loading branch information
Showing
2 changed files
with
20 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-- +goose NO TRANSACTION | ||
-- +goose Up | ||
-- +goose StatementBegin | ||
|
||
ALTER TABLE component_firmware_set_map DROP CONSTRAINT fk_firmware_id_ref_component_firmware_version; | ||
ALTER TABLE component_firmware_set_map ADD CONSTRAINT fk_firmware_id_ref_component_firmware_version FOREIGN KEY (firmware_id) REFERENCES component_firmware_version(id) ON DELETE RESTRICT; | ||
|
||
-- +goose StatementEnd | ||
|
||
-- +goose Down | ||
-- +goose StatementBegin | ||
|
||
ALTER TABLE component_firmware_set_map DROP CONSTRAINT fk_firmware_id_ref_component_firmware_version; | ||
ALTER TABLE component_firmware_set_map ADD CONSTRAINT fk_firmware_id_ref_component_firmware_version FOREIGN KEY (firmware_id) REFERENCES component_firmware_version(id) ON DELETE CASCADE; | ||
|
||
-- +goose StatementEnd |
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