./migrations/047a51b_to_49bed63.sql
This commit is contained in:
parent
e3283d6fdf
commit
61933c88d3
37
047a51b_to_49bed63.sql
Normal file
37
047a51b_to_49bed63.sql
Normal file
@ -0,0 +1,37 @@
|
||||
drop type "public"."usr_username";
|
||||
|
||||
set check_function_bodies = off;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.create_newtype_text(qualified_name text)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
begin
|
||||
execute concat('create type ', qualified_name, ' as (str text);');
|
||||
execute concat( 'create function '
|
||||
, qualified_name || '_to_string(val ' || qualified_name || ')'
|
||||
, E' returns text language sql as \'select (val.str);\';'
|
||||
);
|
||||
execute concat( 'create function '
|
||||
, qualified_name || '_of_string(val text)'
|
||||
, ' returns ' || qualified_name || E' language sql as \'select row(val);\';'
|
||||
);
|
||||
end;
|
||||
$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.usr_username_of_string(val text)
|
||||
RETURNS usr_username
|
||||
LANGUAGE sql
|
||||
AS $function$select row(val);$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.usr_username_to_string(val usr_username)
|
||||
RETURNS text
|
||||
LANGUAGE sql
|
||||
AS $function$select (val.str);$function$
|
||||
;
|
||||
|
||||
create type "public"."usr_username" as ("str" text);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user