-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: [AH-831]: Updated Error Message for Upstream Delete Fail (#3272)
* fix: [AH-831]: Updated Manifest_reference Foreign * fix: [AH-831]: Updated Error Message for Upstream Delete Fail
- Loading branch information
Showing
9 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
app/store/database/migrate/postgres/0095_update_foreign_key_manifest_references.down.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,7 @@ | ||
ALTER TABLE manifest_references | ||
DROP | ||
CONSTRAINT IF EXISTS fk_manifest_references_child_id_mnfsts; | ||
|
||
ALTER TABLE manifest_references | ||
ADD CONSTRAINT fk_manifest_references_child_id_mnfsts | ||
FOREIGN KEY (manifest_ref_child_id) REFERENCES manifests; |
8 changes: 8 additions & 0 deletions
8
app/store/database/migrate/postgres/0095_update_foreign_key_manifest_references.up.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,8 @@ | ||
ALTER TABLE manifest_references | ||
DROP | ||
CONSTRAINT IF EXISTS fk_manifest_references_child_id_mnfsts; | ||
|
||
ALTER TABLE manifest_references | ||
ADD CONSTRAINT fk_manifest_references_child_id_mnfsts | ||
FOREIGN KEY (manifest_ref_child_id) REFERENCES manifests (manifest_id) | ||
ON DELETE CASCADE; |
18 changes: 18 additions & 0 deletions
18
app/store/database/migrate/postgres/0096_update_fk_manifest_references_gc.down.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,18 @@ | ||
DROP FUNCTION IF EXISTS gc_track_deleted_manifest_lists CASCADE; | ||
|
||
CREATE | ||
OR REPLACE FUNCTION gc_track_deleted_manifest_lists() | ||
RETURNS TRIGGER | ||
AS | ||
$$ | ||
BEGIN | ||
INSERT INTO gc_manifest_review_queue (registry_id, manifest_id, review_after, event) | ||
VALUES (OLD.manifest_ref_registry_id, OLD.manifest_ref_child_id, gc_review_after('manifest_list_delete'), | ||
'manifest_list_delete') ON CONFLICT (registry_id, manifest_id) | ||
DO | ||
UPDATE SET review_after = gc_review_after('manifest_list_delete'), | ||
event = 'manifest_list_delete'; | ||
RETURN NULL; | ||
END; | ||
$$ | ||
LANGUAGE plpgsql; |
23 changes: 23 additions & 0 deletions
23
app/store/database/migrate/postgres/0096_update_fk_manifest_references_gc.up.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 @@ | ||
DROP FUNCTION IF EXISTS gc_track_deleted_manifest_lists CASCADE; | ||
|
||
CREATE | ||
OR REPLACE FUNCTION gc_track_deleted_manifest_lists() | ||
RETURNS TRIGGER | ||
AS | ||
$$ | ||
BEGIN | ||
IF | ||
EXISTS ( | ||
SELECT 1 FROM manifests WHERE manifest_id = OLD.manifest_ref_child_id | ||
) THEN | ||
INSERT INTO gc_manifest_review_queue (registry_id, manifest_id, review_after, event) | ||
VALUES (OLD.manifest_ref_registry_id, OLD.manifest_ref_child_id, gc_review_after('manifest_list_delete'), 'manifest_list_delete') | ||
ON CONFLICT (registry_id, manifest_id) | ||
DO | ||
UPDATE SET review_after = gc_review_after('manifest_list_delete'), | ||
event = 'manifest_list_delete'; | ||
END IF; | ||
RETURN NULL; | ||
END; | ||
$$ | ||
LANGUAGE plpgsql; |
37 changes: 37 additions & 0 deletions
37
app/store/database/migrate/sqlite/0095_update_foreign_key_manifest_references.down.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,37 @@ | ||
CREATE TABLE manifest_references_old | ||
( | ||
manifest_ref_id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
manifest_ref_registry_id INTEGER NOT NULL, | ||
manifest_ref_parent_id INTEGER NOT NULL, | ||
manifest_ref_child_id INTEGER NOT NULL, | ||
manifest_ref_created_at BIGINT NOT NULL, | ||
manifest_ref_updated_at BIGINT NOT NULL, | ||
manifest_ref_created_by INTEGER NOT NULL, | ||
manifest_ref_updated_by INTEGER NOT NULL, | ||
CONSTRAINT unique_manifest_references_prt_id_chd_id | ||
UNIQUE (manifest_ref_registry_id, manifest_ref_parent_id, manifest_ref_child_id), | ||
CONSTRAINT fk_manifest_references_parent_id_mnfsts | ||
FOREIGN KEY (manifest_ref_parent_id) REFERENCES manifests | ||
ON DELETE CASCADE, | ||
CONSTRAINT fk_manifest_references_child_id_mnfsts | ||
FOREIGN KEY (manifest_ref_child_id) REFERENCES manifests, | ||
CONSTRAINT check_manifest_references_parent_id_and_child_id_differ | ||
CHECK (manifest_ref_parent_id <> manifest_ref_child_id) | ||
); | ||
|
||
INSERT INTO manifest_references_old (manifest_ref_id, manifest_ref_registry_id, manifest_ref_parent_id, | ||
manifest_ref_child_id, manifest_ref_created_at, manifest_ref_updated_at, | ||
manifest_ref_created_by, manifest_ref_updated_by) | ||
SELECT manifest_ref_id, | ||
manifest_ref_registry_id, | ||
manifest_ref_parent_id, | ||
manifest_ref_child_id, | ||
manifest_ref_created_at, | ||
manifest_ref_updated_at, | ||
manifest_ref_created_by, | ||
manifest_ref_updated_by | ||
FROM manifest_references; | ||
|
||
DROP TABLE manifest_references; | ||
|
||
ALTER TABLE manifest_references_old RENAME TO manifest_references; |
38 changes: 38 additions & 0 deletions
38
app/store/database/migrate/sqlite/0095_update_foreign_key_manifest_references.up.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,38 @@ | ||
CREATE TABLE manifest_references_new | ||
( | ||
manifest_ref_id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
manifest_ref_registry_id INTEGER NOT NULL, | ||
manifest_ref_parent_id INTEGER NOT NULL, | ||
manifest_ref_child_id INTEGER NOT NULL, | ||
manifest_ref_created_at BIGINT NOT NULL, | ||
manifest_ref_updated_at BIGINT NOT NULL, | ||
manifest_ref_created_by INTEGER NOT NULL, | ||
manifest_ref_updated_by INTEGER NOT NULL, | ||
CONSTRAINT unique_manifest_references_prt_id_chd_id | ||
UNIQUE (manifest_ref_registry_id, manifest_ref_parent_id, manifest_ref_child_id), | ||
CONSTRAINT fk_manifest_references_parent_id_mnfsts | ||
FOREIGN KEY (manifest_ref_parent_id) REFERENCES manifests | ||
ON DELETE CASCADE, | ||
CONSTRAINT fk_manifest_references_child_id_mnfsts | ||
FOREIGN KEY (manifest_ref_child_id) REFERENCES manifests (manifest_id) | ||
ON DELETE CASCADE, | ||
CONSTRAINT check_manifest_references_parent_id_and_child_id_differ | ||
CHECK (manifest_ref_parent_id <> manifest_ref_child_id) | ||
); | ||
|
||
INSERT INTO manifest_references_new (manifest_ref_id, manifest_ref_registry_id, manifest_ref_parent_id, | ||
manifest_ref_child_id, manifest_ref_created_at, manifest_ref_updated_at, | ||
manifest_ref_created_by, manifest_ref_updated_by) | ||
SELECT manifest_ref_id, | ||
manifest_ref_registry_id, | ||
manifest_ref_parent_id, | ||
manifest_ref_child_id, | ||
manifest_ref_created_at, | ||
manifest_ref_updated_at, | ||
manifest_ref_created_by, | ||
manifest_ref_updated_by | ||
FROM manifest_references; | ||
|
||
DROP TABLE manifest_references; | ||
|
||
ALTER TABLE manifest_references_new RENAME TO manifest_references; |
Empty file.
Empty file.
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