feat: add tag discriminator
This commit is contained in:
parent
be07aca4c5
commit
96937dfa25
@ -33,10 +33,19 @@ create table public.usr
|
|||||||
, uid uuid not null default gen_random_uuid()
|
, uid uuid not null default gen_random_uuid()
|
||||||
, deleted boolean not null default false
|
, deleted boolean not null default false
|
||||||
, tag public.usr_tag not null
|
, tag public.usr_tag not null
|
||||||
|
, discrim int not null
|
||||||
, password public.hashed_text not null
|
, password public.hashed_text not null
|
||||||
, email public.email not null unique
|
, email public.email not null unique
|
||||||
|
, unique (tag, discrim)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
create function public.usr_tag_count(tag public.usr_tag) returns int language sql stable as $$
|
||||||
|
select count(*) from public.usr u where u.tag = tag;
|
||||||
|
$$;
|
||||||
|
|
||||||
|
alter table public.usr
|
||||||
|
alter column discrim set default public.usr_tag_count(tag);
|
||||||
|
|
||||||
insert into public.usr (tag, password, email)
|
insert into public.usr (tag, password, email)
|
||||||
values (usr_tag_of_string('system'), hashed_text_of_string(''), email_of_string(''));
|
values (usr_tag_of_string('system'), hashed_text_of_string(''), email_of_string(''));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user