fix: seed should always succeed

This commit is contained in:
Orion Kindel 2023-07-20 12:47:52 -05:00
parent 2d99639941
commit 3b3eae9b02
Signed by untrusted user who does not match committer: orion
GPG Key ID: 6D4165AE4C928719
5 changed files with 54 additions and 0 deletions

1
60a672d_to_f9fa376.sql Normal file
View File

@ -0,0 +1 @@

50
6700413_to_68cd9c5.sql Normal file
View File

@ -0,0 +1,50 @@
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);\';'
);
execute concat( 'create cast '
, ' (' || qualified_name || ' as text)'
, ' with function ' || qualified_name || E'_to_string(' || qualified_name || ')'
, ' as assignment;'
);
execute concat( 'create cast '
, ' (text as ' || qualified_name || ')'
, ' with function ' || qualified_name || E'_of_string(text)'
, ' as assignment;'
);
end;
$function$
;
create cast (public.usr_tag as text) with function public.usr_tag_to_string(public.usr_tag) as assignment;
create cast (text as public.usr_tag) with function public.usr_tag_of_string(text) as assignment;
create cast (public.usr_session_key as text) with function public.usr_session_key_to_string(public.usr_session_key) as assignment;
create cast (text as public.usr_session_key) with function public.usr_session_key_of_string(text) as assignment;
create cast (public.grp_tag as text) with function public.grp_tag_to_string(public.grp_tag) as assignment;
create cast (text as public.grp_tag) with function public.grp_tag_of_string(text) as assignment;
create cast (public.community_tag as text) with function public.community_tag_to_string(public.community_tag) as assignment;
create cast (text as public.community_tag) with function public.community_tag_of_string(text) as assignment;
create cast (public.email as text) with function public.email_to_string(public.email) as assignment;
create cast (text as public.email) with function public.email_of_string(text) as assignment;
create cast (public.hashed_text as text) with function public.hashed_text_to_string(public.hashed_text) as assignment;
create cast (text as public.hashed_text) with function public.hashed_text_of_string(text) as assignment;
create cast (human_uuid.huid as text) with function human_uuid.huid_to_string(human_uuid.huid) as assignment;
create cast (text as human_uuid.huid) with function human_uuid.huid_of_string(text) as assignment;

1
a30fe1d_to_6700413.sql Normal file
View File

@ -0,0 +1 @@

View File

@ -35,6 +35,7 @@ begin
('/communities/', root, admins, 'w', 'w', 'r')
, ('/users/', root, admins, 'w', 'w', 'w')
, ('/groups/', root, admins, 'w', 'w', 'w')
on conflict do nothing
;
end;
$$;

1
f9fa376_to_a30fe1d.sql Normal file
View File

@ -0,0 +1 @@