unis_crm/sql/archive/alter_work_checkin_relation...

29 lines
723 B
SQL

alter table work_checkin
add column if not exists biz_type varchar(20);
alter table work_checkin
add column if not exists biz_id bigint;
alter table work_checkin
add column if not exists biz_name varchar(200);
alter table work_checkin
add column if not exists user_name varchar(100);
alter table work_checkin
add column if not exists dept_name varchar(200);
do $$
begin
if not exists (
select 1
from pg_constraint
where conrelid = 'work_checkin'::regclass
and conname = 'work_checkin_biz_type_check'
) then
alter table work_checkin
add constraint work_checkin_biz_type_check
check (biz_type is null or biz_type in ('sales', 'channel', 'opportunity'));
end if;
end $$;