gen_migrations
This commit is contained in:
parent
85aca00ea8
commit
4bc2f54cfd
@ -1,4 +1,4 @@
|
||||
drop type "public"."usr_username";
|
||||
alter type "public"."usr_username" rename attribute "username" to "str" cascade;
|
||||
|
||||
set check_function_bodies = off;
|
||||
|
||||
@ -31,7 +31,3 @@ CREATE OR REPLACE FUNCTION public.usr_username_to_string(val usr_username)
|
||||
LANGUAGE sql
|
||||
AS $function$select (val.str);$function$
|
||||
;
|
||||
|
||||
create type "public"."usr_username" as ("str" text);
|
||||
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -1,9 +1 @@
|
||||
create table "public"."migration" (
|
||||
"from_revision" text not null,
|
||||
"to_revision" text not null,
|
||||
"performed_on" timestamp without time zone not null default now(),
|
||||
"script" text not null
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,75 @@
|
||||
create type "public"."usr_session_device" as enum ('linux', 'macos', 'win', 'android', 'ios', 'other');
|
||||
|
||||
create type "public"."usr_tag_or_email" as ("str" text);
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.usr_tag_or_email_of_string(val text)
|
||||
RETURNS usr_tag_or_email
|
||||
LANGUAGE sql
|
||||
AS $function$select row(val);$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.usr_tag_or_email_to_email(toe usr_tag_or_email)
|
||||
RETURNS email
|
||||
LANGUAGE plpgsql
|
||||
IMMUTABLE
|
||||
AS $function$
|
||||
begin
|
||||
if position('@' in usr_tag_or_email_to_string(toe)) > 0 then
|
||||
return email_of_string(usr_tag_or_email_to_string(toe));
|
||||
else
|
||||
return null;
|
||||
end if;
|
||||
end;
|
||||
$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.usr_tag_or_email_to_string(val usr_tag_or_email)
|
||||
RETURNS text
|
||||
LANGUAGE sql
|
||||
AS $function$select (val.str);$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.usr_tag_or_email_to_tag(toe usr_tag_or_email)
|
||||
RETURNS usr_tag
|
||||
LANGUAGE plpgsql
|
||||
IMMUTABLE
|
||||
AS $function$
|
||||
begin
|
||||
if usr_tag_or_email_to_email(toe) is null then
|
||||
return usr_tag_of_string(usr_tag_or_email_to_string(toe));
|
||||
else
|
||||
return null;
|
||||
end if;
|
||||
end;
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
create type "public"."usr_session_key" as ("str" text);
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.usr_session_key_of_string(val text)
|
||||
RETURNS usr_session_key
|
||||
LANGUAGE sql
|
||||
AS $function$select row(val);$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.usr_session_key_to_string(val usr_session_key)
|
||||
RETURNS text
|
||||
LANGUAGE sql
|
||||
AS $function$select (val.str);$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.usr_session_key_gen()
|
||||
RETURNS usr_session_key
|
||||
LANGUAGE sql
|
||||
AS $function$
|
||||
select usr_session_key_of_string(
|
||||
md5(extract(epoch from now()) || gen_random_bytes(32) :: text)
|
||||
);
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
create table "public"."usr_session" (
|
||||
"id" integer generated always as identity not null,
|
||||
"key" usr_session_key not null default usr_session_key_gen(),
|
||||
@ -52,30 +122,6 @@ end;
|
||||
$function$
|
||||
;
|
||||
|
||||
create type "public"."usr_session_key" as ("str" text);
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.usr_session_key_gen()
|
||||
RETURNS usr_session_key
|
||||
LANGUAGE sql
|
||||
AS $function$
|
||||
select usr_session_key_of_string(
|
||||
md5(extract(epoch from now()) || gen_random_bytes(32) :: text)
|
||||
);
|
||||
$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.usr_session_key_of_string(val text)
|
||||
RETURNS usr_session_key
|
||||
LANGUAGE sql
|
||||
AS $function$select row(val);$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.usr_session_key_to_string(val usr_session_key)
|
||||
RETURNS text
|
||||
LANGUAGE sql
|
||||
AS $function$select (val.str);$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.usr_session_login(tag_or_email usr_tag_or_email, password text, remember boolean DEFAULT false, location text DEFAULT NULL::text, device usr_session_device DEFAULT NULL::usr_session_device, ip inet DEFAULT NULL::inet)
|
||||
RETURNS usr_session_key
|
||||
LANGUAGE plpgsql
|
||||
@ -143,50 +189,4 @@ end;
|
||||
$function$
|
||||
;
|
||||
|
||||
create type "public"."usr_tag_or_email" as ("str" text);
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.usr_tag_or_email_of_string(val text)
|
||||
RETURNS usr_tag_or_email
|
||||
LANGUAGE sql
|
||||
AS $function$select row(val);$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.usr_tag_or_email_to_email(toe usr_tag_or_email)
|
||||
RETURNS email
|
||||
LANGUAGE plpgsql
|
||||
IMMUTABLE
|
||||
AS $function$
|
||||
begin
|
||||
if position('@' in usr_tag_or_email_to_string(toe)) > 0 then
|
||||
return email_of_string(usr_tag_or_email_to_string(toe));
|
||||
else
|
||||
return null;
|
||||
end if;
|
||||
end;
|
||||
$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.usr_tag_or_email_to_string(val usr_tag_or_email)
|
||||
RETURNS text
|
||||
LANGUAGE sql
|
||||
AS $function$select (val.str);$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.usr_tag_or_email_to_tag(toe usr_tag_or_email)
|
||||
RETURNS usr_tag
|
||||
LANGUAGE plpgsql
|
||||
IMMUTABLE
|
||||
AS $function$
|
||||
begin
|
||||
if usr_tag_or_email_to_email(toe) is null then
|
||||
return usr_tag_of_string(usr_tag_or_email_to_string(toe));
|
||||
else
|
||||
return null;
|
||||
end if;
|
||||
end;
|
||||
$function$
|
||||
;
|
||||
|
||||
CREATE TRIGGER trigger_usr_session_immutable_columns BEFORE UPDATE ON public.usr_session FOR EACH ROW EXECUTE FUNCTION do_usr_session_immutable_columns();
|
||||
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -89,5 +89,3 @@ CREATE OR REPLACE FUNCTION public.grp_members_admins()
|
||||
STABLE
|
||||
AS $function$select * from public.grp_members((public.grp_admins()).id)$function$
|
||||
;
|
||||
|
||||
|
||||
|
@ -438,5 +438,3 @@ begin
|
||||
end;
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
|
@ -1,3 +1 @@
|
||||
alter table "public"."migration" drop column "script";
|
||||
|
||||
|
||||
|
@ -545,5 +545,3 @@ AS $function$
|
||||
end;
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -198,5 +198,3 @@ begin
|
||||
end;
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1 @@
|
||||
|
1
56980bf_to_f84b8ed.sql
Normal file
1
56980bf_to_f84b8ed.sql
Normal file
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -60,5 +60,3 @@ AS $function$
|
||||
end;
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
drop function if exists "public"."hashed_text_string"(hashed hashed_text);
|
||||
|
||||
drop type "public"."email";
|
||||
alter type "public"."email" rename attribute "email" to "str";
|
||||
|
||||
drop type "public"."hashed_text";
|
||||
alter type "public"."hashed_text" rename attribute "hashed" to "str";
|
||||
|
||||
set check_function_bodies = off;
|
||||
|
||||
@ -30,8 +30,6 @@ CREATE OR REPLACE FUNCTION public.hashed_text_to_string(val hashed_text)
|
||||
AS $function$select (val.str);$function$
|
||||
;
|
||||
|
||||
create type "public"."email" as ("str" text);
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.hash_text(plain text)
|
||||
RETURNS hashed_text
|
||||
LANGUAGE plpgsql
|
||||
@ -43,8 +41,6 @@ end;
|
||||
$function$
|
||||
;
|
||||
|
||||
create type "public"."hashed_text" as ("str" text);
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.hashed_text_matches(plain text, hashed hashed_text)
|
||||
RETURNS boolean
|
||||
LANGUAGE plpgsql
|
||||
@ -55,5 +51,3 @@ begin
|
||||
end;
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -28,5 +28,3 @@ begin
|
||||
end;
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1 @@
|
||||
|
@ -30,5 +30,3 @@ CREATE OR REPLACE FUNCTION public.hashed_text_string(hashed hashed_text)
|
||||
IMMUTABLE
|
||||
AS $function$select (hashed.hashed);$function$
|
||||
;
|
||||
|
||||
|
||||
|
1
96937df_skipped.sql
Normal file
1
96937df_skipped.sql
Normal file
@ -0,0 +1 @@
|
||||
|
@ -1,10 +1,48 @@
|
||||
drop function if exists "public"."mark_columns_immutable"(schema text, table_ text, columns text[]);
|
||||
|
||||
drop type "public"."usr_username";
|
||||
create type "public"."usr_tag" as ("str" text);
|
||||
|
||||
drop function if exists "public"."usr_username_of_string"(val text);
|
||||
CREATE OR REPLACE FUNCTION public.usr_tag_of_string(val text)
|
||||
RETURNS usr_tag
|
||||
LANGUAGE sql
|
||||
AS $function$select row(val);$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.usr_tag_to_string(val usr_tag)
|
||||
RETURNS text
|
||||
LANGUAGE sql
|
||||
AS $function$select (val.str);$function$
|
||||
;
|
||||
|
||||
|
||||
create type "public"."authz_scope" as ("str" text);
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.authz_scope_of_string(val text)
|
||||
RETURNS authz_scope
|
||||
LANGUAGE sql
|
||||
AS $function$select row(val);$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.authz_scope_to_string(val authz_scope)
|
||||
RETURNS text
|
||||
LANGUAGE sql
|
||||
AS $function$select (val.str);$function$
|
||||
;
|
||||
|
||||
create type "public"."community_tag" as ("str" text);
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.community_tag_of_string(val text)
|
||||
RETURNS community_tag
|
||||
LANGUAGE sql
|
||||
AS $function$select row(val);$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.community_tag_to_string(val community_tag)
|
||||
RETURNS text
|
||||
LANGUAGE sql
|
||||
AS $function$select (val.str);$function$
|
||||
;
|
||||
|
||||
drop function if exists "public"."usr_username_to_string"(val usr_username);
|
||||
|
||||
create table "public"."community" (
|
||||
"id" integer generated always as identity not null,
|
||||
@ -218,35 +256,6 @@ AS $function$
|
||||
end;
|
||||
$function$
|
||||
;
|
||||
|
||||
create type "public"."authz_scope" as ("str" text);
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.authz_scope_of_string(val text)
|
||||
RETURNS authz_scope
|
||||
LANGUAGE sql
|
||||
AS $function$select row(val);$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.authz_scope_to_string(val authz_scope)
|
||||
RETURNS text
|
||||
LANGUAGE sql
|
||||
AS $function$select (val.str);$function$
|
||||
;
|
||||
|
||||
create type "public"."community_tag" as ("str" text);
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.community_tag_of_string(val text)
|
||||
RETURNS community_tag
|
||||
LANGUAGE sql
|
||||
AS $function$select row(val);$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.community_tag_to_string(val community_tag)
|
||||
RETURNS text
|
||||
LANGUAGE sql
|
||||
AS $function$select (val.str);$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.do_community_audit()
|
||||
RETURNS trigger
|
||||
LANGUAGE plpgsql
|
||||
@ -665,20 +674,6 @@ AS $function$
|
||||
$function$
|
||||
;
|
||||
|
||||
create type "public"."usr_tag" as ("str" text);
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.usr_tag_of_string(val text)
|
||||
RETURNS usr_tag
|
||||
LANGUAGE sql
|
||||
AS $function$select row(val);$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.usr_tag_to_string(val usr_tag)
|
||||
RETURNS text
|
||||
LANGUAGE sql
|
||||
AS $function$select (val.str);$function$
|
||||
;
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.do_usr_audit()
|
||||
RETURNS trigger
|
||||
LANGUAGE plpgsql
|
||||
@ -731,4 +726,8 @@ CREATE TRIGGER trigger_community_nonmember_scope_audit AFTER INSERT OR DELETE OR
|
||||
|
||||
CREATE TRIGGER trigger_community_nonmember_scope_immutable_columns BEFORE UPDATE ON public.community_nonmember_scope FOR EACH ROW EXECUTE FUNCTION do_community_nonmember_scope_immutable_columns();
|
||||
|
||||
drop function if exists "public"."usr_username_of_string"(val text);
|
||||
|
||||
drop function if exists "public"."usr_username_to_string"(val usr_username);
|
||||
|
||||
drop type "public"."usr_username";
|
||||
|
@ -0,0 +1 @@
|
||||
|
1202
be07aca_to_56957d3.sql
Normal file
1202
be07aca_to_56957d3.sql
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -558,5 +558,3 @@ CREATE TRIGGER trigger_thread_feed_immutable_columns BEFORE UPDATE ON public.thr
|
||||
CREATE TRIGGER trigger_thread_feed_soft_delete BEFORE DELETE ON public.thread_feed FOR EACH ROW EXECUTE FUNCTION do_thread_feed_soft_delete();
|
||||
|
||||
CREATE TRIGGER trigger_usr_immutable_columns BEFORE UPDATE ON public.usr FOR EACH ROW EXECUTE FUNCTION do_usr_immutable_columns();
|
||||
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -1,3 +1,9 @@
|
||||
create type "public"."email" as ("email" text);
|
||||
|
||||
create type "public"."hashed_text" as ("hashed" text);
|
||||
|
||||
create type "public"."usr_username" as ("username" text);
|
||||
|
||||
create type "public"."audit_kind" as enum ('modify', 'delete', 'create');
|
||||
|
||||
create type "public"."thread_kind" as enum ('post', 'short', 'message');
|
||||
@ -136,14 +142,6 @@ AS $function$
|
||||
$function$
|
||||
;
|
||||
|
||||
create type "public"."email" as ("email" text);
|
||||
|
||||
create type "public"."hashed_text" as ("hashed" text);
|
||||
|
||||
create type "public"."usr_username" as ("username" text);
|
||||
|
||||
CREATE TRIGGER trigger_usr_audit AFTER INSERT OR UPDATE ON public.usr FOR EACH ROW EXECUTE FUNCTION do_usr_audit();
|
||||
|
||||
CREATE TRIGGER trigger_usr_soft_delete BEFORE DELETE ON public.usr FOR EACH ROW EXECUTE FUNCTION do_usr_soft_delete();
|
||||
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
|
Loading…
Reference in New Issue
Block a user