-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: delete an ESP in the backend (#219)
* feat: delete an ESP in the backend * fix: the deleting function is now functional Closes: #218
- Loading branch information
Showing
8 changed files
with
58 additions
and
20 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
database/migration/deploy/new_way_delete_esp_permission.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 @@ | ||
-- Deploy climat-guardian:new_way_delete_esp_permission to pg | ||
|
||
-- Function to DELETE on data and esp tables | ||
|
||
BEGIN; | ||
|
||
-- Delete the function if exists | ||
DROP FUNCTION IF EXISTS api.delete_esp_data_and_esp; | ||
|
||
-- Create the function | ||
CREATE FUNCTION api.delete_esp_data_and_esp(id_data INT) | ||
RETURNS VOID AS $$ | ||
|
||
BEGIN | ||
|
||
-- DELETE on data and esp tables | ||
DELETE FROM api.data WHERE api.data.esp_id = id_data; | ||
DELETE FROM api.esp WHERE api.esp.id = id_data; | ||
|
||
END; | ||
$$ LANGUAGE plpgsql; | ||
|
||
COMMIT; |
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
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
10 changes: 10 additions & 0 deletions
10
database/migration/revert/new_way_delete_esp_permission.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,10 @@ | ||
-- Revert climat-guardian:new_way_delete_esp_permission from pg | ||
|
||
BEGIN; | ||
|
||
|
||
-- DELETE the function if it exists | ||
DROP FUNCTION IF EXISTS api.delete_esp_data_and_esp(id); | ||
|
||
|
||
COMMIT; |
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
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 @@ | ||
-- Verify climat-guardian:new_way_delete_esp_permission on pg | ||
|
||
BEGIN; | ||
|
||
-- XXX Add verifications here. | ||
|
||
ROLLBACK; |
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