-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3295 from bcgov/NDT-344-Pending-Change-Request-no…
…t-archiving-old-records fix: archiving old pending change request records
- Loading branch information
Showing
7 changed files
with
112 additions
and
28 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
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,25 @@ | ||
-- Deploy ccbc:mutations/create_pending_change_request.sql to pg | ||
|
||
begin; | ||
|
||
create or replace function ccbc_public.create_pending_change_request(_application_id int, _is_pending boolean, _comment varchar default null) returns ccbc_public.application_pending_change_request as $$ | ||
declare | ||
new_request_id int; | ||
begin | ||
|
||
insert into ccbc_public.application_pending_change_request (application_id, comment, is_pending) | ||
values (_application_id, _comment, _is_pending) returning id into new_request_id; | ||
|
||
update ccbc_public.application_pending_change_request | ||
set archived_at = now() | ||
where application_id = _application_id and archived_at is null and id != new_request_id; | ||
|
||
return (select row(ccbc_public.application_pending_change_request.*) from ccbc_public.application_pending_change_request where id = new_request_id); | ||
|
||
end; | ||
$$ language plpgsql volatile; | ||
|
||
grant execute on function ccbc_public.create_pending_change_request to ccbc_analyst; | ||
grant execute on function ccbc_public.create_pending_change_request to ccbc_admin; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- Revert ccbc:mutations/create_pending_change_request from pg | ||
|
||
BEGIN; | ||
|
||
drop function ccbc_public.create_pending_change_request; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -564,3 +564,4 @@ tables/application_pending_change_request 2024-05-03T20:55:21Z ,,, <ryohani89@NH | |
@1.161.0 2024-05-15T17:59:55Z CCBC Service Account <[email protected]> # release v1.161.0 | ||
tables/cbc 2024-05-08T17:56:10Z Rafael Solorzano <[email protected]> # add cbc projects table for individual cbc projects | ||
tables/cbc_data 2024-05-08T18:08:06Z Rafael Solorzano <[email protected]> # table to hold the json data for individual cbc projects | ||
mutations/create_pending_change_request 2024-05-22T16:44:01Z ,,, <ryohani89@NH504670> # add create application pending change request mutation |