-
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.
fix: replace default create_fuel_naics_code mutation
- Loading branch information
Showing
8 changed files
with
51 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
-- Deploy ggircs-portal:mutations/create_fuel_naics_code to pg | ||
-- requires: tables/fuel_naics_code | ||
|
||
begin; | ||
|
||
create or replace function ggircs_portal.create_fuel_naics_code( | ||
fuel_id_input int, | ||
naics_code_id_input int | ||
) returns ggircs_portal.fuel_naics_code as $function$ | ||
|
||
declare | ||
new_id int; | ||
result ggircs_portal.fuel_naics_code; | ||
begin | ||
|
||
-- Reset deleted at/by and update description on conflict | ||
insert into ggircs_portal.fuel_naics_code(fuel_id, naics_code_id) | ||
values (fuel_id_input, naics_code_id_input) | ||
on conflict(fuel_id, naics_code_id) do update set deleted_at=null, deleted_by=null | ||
returning id into new_id; | ||
|
||
select * from ggircs_portal.fuel_naics_code where id=new_id into result; | ||
return result; | ||
|
||
end; | ||
|
||
$function$ language plpgsql volatile; | ||
|
||
grant execute on function ggircs_portal.create_fuel_naics_code to ciip_administrator; | ||
comment on function ggircs_portal.create_fuel_naics_code is 'This custom create mutation does an upsert on conflict of the fuel_id & naics_code_id columns, setting the deleted at/by columsn to null'; | ||
|
||
commit; |
21 changes: 0 additions & 21 deletions
21
schema/deploy/mutations/create_fuel_naics_code_mutation.sql
This file was deleted.
Oops, something went wrong.
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 ggircs-portal:mutations/create_fuel_naics_code from pg | ||
|
||
begin; | ||
|
||
drop function ggircs_portal.create_fuel_naics_code; | ||
|
||
commit; |
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
-- Verify ggircs-portal:mutations/create_fuel_naics_code on pg | ||
|
||
begin; | ||
|
||
select pg_get_functiondef('ggircs_portal.create_fuel_naics_code(int, int)'::regprocedure); | ||
|
||
rollback; |
This file was deleted.
Oops, something went wrong.