db/schema/020_user.sql

31 lines
1023 B
MySQL
Raw Normal View History

2023-06-11 16:26:39 +00:00
select create_newtype_text('public.usr_tag');
2023-06-10 04:51:28 +00:00
create table public.usr
( id int not null primary key generated always as identity
, uid uuid not null default gen_random_uuid()
, deleted boolean not null default false
2023-06-11 16:26:39 +00:00
, tag public.usr_tag not null
2023-06-10 04:51:28 +00:00
, password public.hashed_text not null
, email public.email not null unique
);
2023-06-11 17:01:51 +00:00
insert into public.usr (tag, password, email)
overriding system value
values (usr_tag_of_string('system'), hashed_text_of_string(''), email_of_string(''));
2023-06-11 16:26:39 +00:00
select audit( 'public'
, 'usr'
, array[ row('tag', 'public.usr_tag')
, row('password', 'public.hashed_text')
, row('email', 'public.email')
] :: audited_column[]
, soft_delete => true
);
2023-06-10 22:43:27 +00:00
2023-06-11 16:26:39 +00:00
select immutable( 'public'
, 'usr'
, array[ 'id'
, 'uid'
]
);