xykj-plus/xykj-admin-plus/script/sql/update/postgres/update_candidate_table.sql
2026-06-13 13:48:51 +08:00

72 lines
2.8 KiB
SQL

-- ----------------------------
-- 候选人表结构更新脚本 (PostgreSQL)
-- 说明:此脚本用于为候选人表添加缺失字段
-- 请根据实际情况谨慎执行,建议先备份数据
-- ----------------------------
-- ----------------------------
-- 第一步:备份原有数据(可选,建议执行)
-- ----------------------------
-- create table biz_candidate_backup as select * from biz_candidate;
-- ----------------------------
-- 第二步:添加缺失字段
-- ----------------------------
-- 沟通日期
alter table biz_candidate add column if not exists communication_date date;
-- 项目组
alter table biz_candidate add column if not exists project_group varchar(100);
-- 统招是否
alter table biz_candidate add column if not exists is_unified_recruitment char(1);
-- 专业
alter table biz_candidate add column if not exists major varchar(100);
-- 是否愿意外派
alter table biz_candidate add column if not exists willing_to_outsource char(1);
-- 是否在职
alter table biz_candidate add column if not exists is_employed char(1);
-- 离职周期多久
alter table biz_candidate add column if not exists resignation_cycle varchar(50);
-- 什么时候方便面试
alter table biz_candidate add column if not exists interview_availability varchar(200);
-- 候选人住哪里
alter table biz_candidate add column if not exists residence_location varchar(200);
-- 是否加微信
alter table biz_candidate add column if not exists wechat_added char(1);
-- ----------------------------
-- 第三步:添加字段注释
-- ----------------------------
comment on column biz_candidate.communication_date is '沟通日期';
comment on column biz_candidate.project_group is '项目组';
comment on column biz_candidate.is_unified_recruitment is '统招是否(0否 1是)';
comment on column biz_candidate.major is '专业';
comment on column biz_candidate.willing_to_outsource is '是否愿意外派(0否 1是)';
comment on column biz_candidate.is_employed is '是否在职(0否 1是)';
comment on column biz_candidate.resignation_cycle is '离职周期多久';
comment on column biz_candidate.interview_availability is '什么时候方便面试';
comment on column biz_candidate.residence_location is '候选人住哪里';
comment on column biz_candidate.wechat_added is '是否加微信(0否 1是)';
-- ----------------------------
-- 第三步:添加唯一约束
-- ----------------------------
-- 删除可能存在的旧索引
drop index if exists uk_name;
drop index if exists uk_phone_number;
drop index if exists uk_name_phone;
-- 创建唯一索引:姓名唯一(处理空值)
create unique index uk_name on biz_candidate(name) where name is not null;
-- 创建唯一索引:手机号码唯一(处理空值)
create unique index uk_phone_number on biz_candidate(phone_number) where phone_number is not null;