-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: delete from system_vulnerable_package when deleting system
- Loading branch information
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
database/schema/upgrade_scripts/125-delete_system_vuln_package.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,19 @@ | ||
CREATE OR REPLACE FUNCTION delete_system(inventory_id_in UUID) | ||
RETURNS TABLE (deleted_inventory_id UUID) AS | ||
$delete_system$ | ||
DECLARE | ||
system_id_in INT; | ||
rh_account_id_in INT; | ||
BEGIN | ||
-- opt out to refresh cache and then delete | ||
SELECT id, rh_account_id FROM system_platform WHERE inventory_id = inventory_id_in INTO system_id_in, rh_account_id_in FOR UPDATE; | ||
UPDATE system_platform SET opt_out = true WHERE id = system_id_in; | ||
DELETE FROM system_vulnerabilities WHERE system_id = system_id_in AND rh_account_id = rh_account_id_in; | ||
DELETE FROM system_vulnerable_package WHERE system_id = system_id_in AND rh_account_id = rh_account_id_in; | ||
DELETE FROM system_repo WHERE system_id = system_id_in; | ||
RETURN QUERY DELETE FROM system_platform WHERE id = system_id_in RETURNING inventory_id; | ||
END; | ||
$delete_system$ | ||
LANGUAGE 'plpgsql'; | ||
|
||
GRANT SELECT, DELETE ON system_vulnerable_package TO ve_db_user_taskomatic; |
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