-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Cleanup Save & Return scheduled events when lowcal_session reco…
…rd is deleted (#1126)
- Loading branch information
1 parent
a729019
commit b142371
Showing
5 changed files
with
29 additions
and
2 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
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
2 changes: 2 additions & 0 deletions
2
hasura.planx.uk/migrations/1661380924586_run_sql_migration/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,2 @@ | ||
DROP TRIGGER IF EXISTS delete_lowcal_session_scheduled_events_trigger ON lowcal_sessions; | ||
DROP FUNCTION IF EXISTS delete_lowcal_session_scheduled_events; |
20 changes: 20 additions & 0 deletions
20
hasura.planx.uk/migrations/1661380924586_run_sql_migration/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,20 @@ | ||
CREATE OR REPLACE FUNCTION | ||
delete_lowcal_session_scheduled_events() | ||
RETURNS TRIGGER AS $$ | ||
BEGIN | ||
DELETE FROM hdb_catalog.hdb_scheduled_events | ||
WHERE comment IN ( | ||
'reminder_' || OLD.id, | ||
'expiry_' || OLD.id | ||
); | ||
RETURN NULL; | ||
END | ||
$$ LANGUAGE plpgsql VOLATILE; | ||
|
||
DROP TRIGGER IF EXISTS delete_lowcal_session_scheduled_events_trigger ON lowcal_sessions; | ||
CREATE TRIGGER delete_lowcal_session_scheduled_events_trigger | ||
AFTER DELETE ON lowcal_sessions FOR EACH ROW | ||
EXECUTE PROCEDURE delete_lowcal_session_scheduled_events(); | ||
|
||
COMMENT ON TRIGGER delete_lowcal_session_scheduled_events_trigger ON lowcal_sessions | ||
IS 'Delete linked scheduled events (reminder and expiry emails) when deleting a lowcal_session'; |