db/schema/020_user.sql
2023-06-10 17:57:23 -05:00

26 lines
1.1 KiB
SQL

select create_newtype_text('public.usr_username');
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
, username public.usr_username not null
, password public.hashed_text not null
, email public.email not null unique
);
select setup_audit_and_soft_delete( 'public'
, 'usr'
, array[ row('username', 'public.usr_username')
, row('password', 'public.hashed_text')
, row('email', 'public.email')
] :: audited_column[]
);
select mark_columns_immutable( 'public'
, 'usr'
, array[ 'id'
, 'uid'
]
);