forked from wangziqi/gongxue-base
19 lines
563 B
SQL
19 lines
563 B
SQL
alter table public.platform_users
|
|
add column if not exists status text not null default 'active';
|
|
|
|
do $$
|
|
begin
|
|
if not exists (select 1 from pg_constraint where conname = 'platform_users_status_check') then
|
|
alter table public.platform_users
|
|
add constraint platform_users_status_check
|
|
check (status in ('active', 'disabled'));
|
|
end if;
|
|
end $$;
|
|
|
|
update public.platform_users
|
|
set status = 'active'
|
|
where status is null;
|
|
|
|
create index if not exists idx_platform_users_role_status
|
|
on public.platform_users(primary_role, status, created_at desc);
|