db/schema/0012_newtype.sql
Orion Kindel 56957d380a
Some checks failed
migrate-devel / migrate-devel (push) Failing after 7s
migrate-stage / migrate-stage (push) Failing after 8s
feat: permissions
2023-07-14 21:13:33 -04:00

17 lines
600 B
PL/PgSQL

create function create_newtype_text(qualified_name text)
returns void
language plpgsql
as $$
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;
$$;