27 lines
773 B
MySQL
27 lines
773 B
MySQL
|
-- Deploy camper:add_campsite_type_option to pg
|
||
|
-- requires: roles
|
||
|
-- requires: schema_camper
|
||
|
-- requires: campsite_type_option
|
||
|
-- requires: campsite_type
|
||
|
|
||
|
begin;
|
||
|
|
||
|
set search_path to camper, public;
|
||
|
|
||
|
create or replace function add_campsite_type_option(type_slug uuid, name text, min integer, max integer) returns integer as
|
||
|
$$
|
||
|
insert into campsite_type_option (campsite_type_id, name, range)
|
||
|
select campsite_type_id, add_campsite_type_option.name, int4range(min, max, '[]')
|
||
|
from campsite_type
|
||
|
where slug = type_slug
|
||
|
returning campsite_type_option_id
|
||
|
;
|
||
|
$$
|
||
|
language sql
|
||
|
;
|
||
|
|
||
|
revoke execute on function add_campsite_type_option(uuid, text, integer, integer) from public;
|
||
|
grant execute on function add_campsite_type_option(uuid, text, integer, integer) to admin;
|
||
|
|
||
|
commit;
|