-- 2.06版本sql
alter table trading_platform add `short_auto_sign_url` varchar(1024) DEFAULT NULL COMMENT '自动签署短链接';
alter table trading_platform add `short_auto_sign_url_create` timestamp  DEFAULT CURRENT_TIMESTAMP COMMENT '自动签署创建时间';
alter table trading_platform add `short_auth_url` varchar(1024) DEFAULT NULL COMMENT '二网认证短链接';
alter table trading_platform add `short_auth_url_create` timestamp  DEFAULT CURRENT_TIMESTAMP COMMENT '二网认证短链接创建时间';
update trading_platform set short_auto_sign_url_create = gmt_create;
update trading_platform set short_auth_url_create = gmt_create;


alter table enterprise_customer_info add `short_auth_url` varchar(1024) DEFAULT NULL COMMENT '自动签署短链接';
alter table enterprise_customer_info add `short_auth_url_create` timestamp  DEFAULT CURRENT_TIMESTAMP COMMENT '自动签署创建时间';
update enterprise_customer_info set short_auth_url_create = gmt_create;



alter table settlement_electronic_info add `short_contract_link` varchar(1024) DEFAULT NULL COMMENT '签署短链接';
alter table settlement_electronic_info add `short_contract_link_create` timestamp  DEFAULT CURRENT_TIMESTAMP COMMENT '签署短链接创建时间';
update settlement_electronic_info set short_contract_link_create = gmt_create;


alter table purch_contract_electronic_info add `short_contract_link` varchar(1024) DEFAULT NULL COMMENT '签署短链接';
alter table purch_contract_electronic_info add `short_contract_link_create` timestamp  DEFAULT CURRENT_TIMESTAMP COMMENT '签署短链接创建时间';
update purch_contract_electronic_info set short_contract_link_create = gmt_create;


alter table purch_contract_supplement_electronic_info add `short_contract_link` varchar(1024) DEFAULT NULL COMMENT '签署短链接';
alter table purch_contract_supplement_electronic_info add `short_contract_link_create` timestamp  DEFAULT CURRENT_TIMESTAMP COMMENT '签署短链接创建时间';
update purch_contract_supplement_electronic_info set short_contract_link_create = gmt_create;

alter table purch_contract_basic_info_history add `partner_entity_id` bigint(20) DEFAULT NULL  COMMENT '主表id';
UPDATE purch_contract_basic_info_history t1 INNER JOIN purch_contract_basic_info t2 ON t1.contract_number = t2.contract_number SET t1.partner_entity_id = t2.id;

-- 添加合同补充信息历史表
DROP TABLE IF EXISTS `purch_contract_replenish_info_history`;
CREATE TABLE purch_contract_replenish_info_history like purch_contract_replenish_info;
INSERT INTO purch_contract_replenish_info_history select * FROM purch_contract_replenish_info;
alter table purch_contract_replenish_info_history add `purch_contract_basic_info_history_id` bigint(20) DEFAULT NULL  COMMENT '采购合同基本信息历史表Id';
alter table purch_contract_replenish_info_history add `purch_contract_approval_id` bigint(20) DEFAULT NULL  COMMENT '采购合同审核表Id';
UPDATE purch_contract_replenish_info_history t1
    INNER JOIN purch_contract_basic_info_history t2 on t2.partner_entity_id = t1.purch_contract_basic_info_id
    SET t1.purch_contract_basic_info_history_id = t2.id;
update purch_contract_replenish_info_history t1 INNER JOIN purch_contract_approval t2 on t1.purch_contract_basic_info_id = t2.purch_contract_basic_info_id set t1.purch_contract_approval_id = t2.id;

-- 添加质量与验收历史表
DROP TABLE IF EXISTS `purch_contract_quality_accept_history`;
CREATE TABLE purch_contract_quality_accept_history like purch_contract_quality_accept;
INSERT INTO purch_contract_quality_accept_history select * FROM purch_contract_quality_accept;
alter table purch_contract_quality_accept_history add `purch_contract_basic_info_history_id` bigint(20) DEFAULT NULL  COMMENT '采购合同基本信息历史表Id';
update purch_contract_quality_accept_history t1
    INNER JOIN purch_contract_basic_info_history t2 on t2.partner_entity_id = t1.purch_contract_basic_info_id
    SET t1.purch_contract_basic_info_history_id = t2.id;

-- 添加交货规定历史表
DROP TABLE IF EXISTS `purch_contract_deliver_clause_history`;
CREATE TABLE purch_contract_deliver_clause_history like purch_contract_deliver_clause;
INSERT INTO purch_contract_deliver_clause_history select * FROM purch_contract_deliver_clause;
alter table purch_contract_deliver_clause_history add `purch_contract_basic_info_history_id` bigint(20) DEFAULT NULL  COMMENT '采购合同基本信息历史表Id';
update purch_contract_deliver_clause_history t1
    INNER JOIN purch_contract_basic_info_history t2 on t2.partner_entity_id = t1.purch_contract_basic_info_id
    SET t1.purch_contract_basic_info_history_id = t2.id;

-- 添加供货商责任历史表
DROP TABLE IF EXISTS `purch_contract_seller_blame_history`;
CREATE TABLE purch_contract_seller_blame_history like purch_contract_seller_blame;
INSERT INTO purch_contract_seller_blame_history select * FROM purch_contract_seller_blame;
alter table purch_contract_seller_blame_history add `purch_contract_basic_info_history_id` bigint(20) DEFAULT NULL  COMMENT '采购合同基本信息历史表Id';
update purch_contract_seller_blame_history t1
    INNER JOIN purch_contract_basic_info_history t2 on t2.partner_entity_id = t1.purch_contract_basic_info_id
    SET t1.purch_contract_basic_info_history_id = t2.id;

-- 添加合同违约条款历史表
DROP TABLE IF EXISTS `purch_contract_punish_clause_history`;
CREATE TABLE purch_contract_punish_clause_history like purch_contract_punish_clause;
INSERT INTO purch_contract_punish_clause_history select * FROM purch_contract_punish_clause;
alter table purch_contract_punish_clause_history add `purch_contract_basic_info_history_id` bigint(20) DEFAULT NULL  COMMENT '采购合同基本信息历史表Id';
update purch_contract_punish_clause_history t1
    INNER JOIN purch_contract_basic_info_history t2 on t2.partner_entity_id = t1.purch_contract_basic_info_id
    SET t1.purch_contract_basic_info_history_id = t2.id;

-- 添加其他条款历史表
DROP TABLE IF EXISTS `purch_contract_other_clause_history`;
CREATE TABLE purch_contract_other_clause_history like purch_contract_other_clause;
INSERT INTO purch_contract_other_clause_history select * FROM purch_contract_other_clause;
alter table purch_contract_other_clause_history add `purch_contract_basic_info_history_id` bigint(20) DEFAULT NULL  COMMENT '采购合同基本信息历史表Id';
update purch_contract_other_clause_history t1
    INNER JOIN purch_contract_basic_info_history t2 on t2.partner_entity_id = t1.purch_contract_basic_info_id
    SET t1.purch_contract_basic_info_history_id = t2.id;

-- 以上为2.0.6上线脚本



