./migrations/94501b7_to_047a51b.sql

This commit is contained in:
Orion Kindel 2023-07-17 14:13:35 -04:00
parent 447e223547
commit e3283d6fdf
Signed by untrusted user who does not match committer: orion
GPG Key ID: 6D4165AE4C928719

34
94501b7_to_047a51b.sql Normal file
View File

@ -0,0 +1,34 @@
create extension if not exists "pgcrypto" with schema "public" version '1.3';
set check_function_bodies = off;
CREATE OR REPLACE FUNCTION public.hash_text(plain text)
RETURNS hashed_text
LANGUAGE plpgsql
IMMUTABLE
AS $function$
begin
return row(crypt(plain, gen_salt('bf')));
end;
$function$
;
CREATE OR REPLACE FUNCTION public.hashed_text_matches(plain text, hashed hashed_text)
RETURNS boolean
LANGUAGE plpgsql
IMMUTABLE
AS $function$
begin
return hashed_text_string(hashed) = crypt(plain, hashed_text_string(hashed));
end;
$function$
;
CREATE OR REPLACE FUNCTION public.hashed_text_string(hashed hashed_text)
RETURNS text
LANGUAGE sql
IMMUTABLE
AS $function$select (hashed.hashed);$function$
;