refactoring: move sql files
This commit is contained in:
18
resources/sql/functions/user/insert_user.sql
Normal file
18
resources/sql/functions/user/insert_user.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
create or replace procedure insert_user(inout resource json) language plpgsql as
|
||||
$$
|
||||
declare
|
||||
new_id uuid;
|
||||
begin
|
||||
insert into "user" (username, password, blocked_at)
|
||||
select
|
||||
username,
|
||||
crypt(resource->>'plain_password', gen_salt('bf', 8)),
|
||||
case when blocked_at is not null then now() else null end
|
||||
from json_populate_record(null::"user", resource)
|
||||
returning id into new_id;
|
||||
|
||||
select find_user_by_id(new_id) into resource;
|
||||
end;
|
||||
$$;
|
||||
|
||||
-- drop procedure if exists insert_user(inout json);
|
||||
Reference in New Issue
Block a user