
-- ----------------------------
-- Table structure for zh_external_data
-- ----------------------------

CREATE TABLE `zh_external_data` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tid` int(11) NOT NULL COMMENT '标段id',
  `sid` int(11) NOT NULL DEFAULT '-1' COMMENT '所属期id，-1表示整个标段共用',
  `ex_type` varchar(20) CHARACTER SET utf8 NOT NULL COMMENT '额外数据 - 类型(''fl'': 富龙接口数据)',
  `ex_field` varchar(20) CHARACTER SET utf8 NOT NULL COMMENT '额外数据 - 名称(具体细分由ex_type决定)',
  `ex_value` text CHARACTER SET utf8 COMMENT '额外数据 - 值',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='外部所需数据\r\n非计量支付内部运行所需数据，当接入外部系统时，这些系统可能要求我们提供某些额外的数据，例如：富龙接口，wbs_code\r\n类似数据，均存储在这里';

-- ----------------------------
-- zh_stage_bonus add column 发文单位
-- ----------------------------
ALTER TABLE `zh_stage_bonus`
ADD COLUMN `doc_co`  varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '发文单位' AFTER `code`;

-- ----------------------------
-- zh_stage_bonus add column 依据材料 - 文件列表
-- ----------------------------
ALTER TABLE `zh_stage_bonus`
ADD COLUMN `proof_file`  text CHARACTER SET utf8 NULL COMMENT '依据材料 - 文件列表(json)' AFTER `proof`;


-- 更改 zh_role_rpt_rel 结构，增加stage id
ALTER TABLE `zh_role_rpt_rel`
ADD COLUMN `sid` INT NULL AFTER `rpt_id`,
DROP INDEX `tender_idx` ,
ADD INDEX `tender_idx` (`tender_id` ASC, `rpt_id` ASC);
;

-- 然后顺便初始化一下sid
update zh_role_rpt_rel set sid = 1044 where id = 275;
update zh_role_rpt_rel set sid = 1044 where id = 276;
update zh_role_rpt_rel set sid = 1044 where id = 277;
update zh_role_rpt_rel set sid = 1044 where id = 281;
update zh_role_rpt_rel set sid = 1044 where id = 282;
update zh_role_rpt_rel set sid = 1052 where id = 21;
update zh_role_rpt_rel set sid = 1074 where id = 60;
update zh_role_rpt_rel set sid = 1074 where id = 61;
update zh_role_rpt_rel set sid = 1074 where id = 62;
update zh_role_rpt_rel set sid = 1078 where id = 23;
update zh_role_rpt_rel set sid = 1083 where id = 24;
update zh_role_rpt_rel set sid = 1083 where id = 25;
update zh_role_rpt_rel set sid = 1084 where id = 37;
update zh_role_rpt_rel set sid = 1084 where id = 38;
update zh_role_rpt_rel set sid = 1084 where id = 39;
update zh_role_rpt_rel set sid = 1086 where id = 28;
update zh_role_rpt_rel set sid = 1089 where id = 29;
update zh_role_rpt_rel set sid = 1089 where id = 30;
update zh_role_rpt_rel set sid = 1090 where id = 31;
update zh_role_rpt_rel set sid = 1096 where id = 121;
update zh_role_rpt_rel set sid = 1162 where id = 35;
update zh_role_rpt_rel set sid = 1162 where id = 36;
update zh_role_rpt_rel set sid = 1162 where id = 176;
update zh_role_rpt_rel set sid = 1169 where id = 55;
update zh_role_rpt_rel set sid = 1185 where id = 40;
update zh_role_rpt_rel set sid = 1193 where id = 53;
update zh_role_rpt_rel set sid = 1225 where id = 54;
update zh_role_rpt_rel set sid = 1264 where id = 232;
update zh_role_rpt_rel set sid = 1264 where id = 274;
update zh_role_rpt_rel set sid = 1265 where id = 59;
update zh_role_rpt_rel set sid = 1296 where id = 64;
update zh_role_rpt_rel set sid = 1296 where id = 65;
update zh_role_rpt_rel set sid = 1296 where id = 66;
update zh_role_rpt_rel set sid = 1298 where id = 69;
update zh_role_rpt_rel set sid = 1298 where id = 70;
update zh_role_rpt_rel set sid = 1299 where id = 82;
update zh_role_rpt_rel set sid = 1299 where id = 84;
update zh_role_rpt_rel set sid = 1299 where id = 85;
update zh_role_rpt_rel set sid = 1299 where id = 86;
update zh_role_rpt_rel set sid = 1299 where id = 87;
update zh_role_rpt_rel set sid = 1299 where id = 88;
update zh_role_rpt_rel set sid = 1299 where id = 89;
update zh_role_rpt_rel set sid = 1299 where id = 90;
update zh_role_rpt_rel set sid = 1300 where id = 76;
update zh_role_rpt_rel set sid = 1300 where id = 77;
update zh_role_rpt_rel set sid = 1300 where id = 78;
update zh_role_rpt_rel set sid = 1300 where id = 79;
update zh_role_rpt_rel set sid = 1300 where id = 80;
update zh_role_rpt_rel set sid = 1303 where id = 131;
update zh_role_rpt_rel set sid = 1303 where id = 132;
update zh_role_rpt_rel set sid = 1303 where id = 133;
update zh_role_rpt_rel set sid = 1303 where id = 134;
update zh_role_rpt_rel set sid = 1303 where id = 135;
update zh_role_rpt_rel set sid = 1303 where id = 136;
update zh_role_rpt_rel set sid = 1311 where id = 71;
update zh_role_rpt_rel set sid = 1311 where id = 72;
update zh_role_rpt_rel set sid = 1311 where id = 73;
update zh_role_rpt_rel set sid = 1311 where id = 74;
update zh_role_rpt_rel set sid = 1311 where id = 75;
update zh_role_rpt_rel set sid = 1311 where id = 83;
update zh_role_rpt_rel set sid = 1318 where id = 122;
update zh_role_rpt_rel set sid = 1321 where id = 81;
update zh_role_rpt_rel set sid = 1328 where id = 92;
update zh_role_rpt_rel set sid = 1328 where id = 112;
update zh_role_rpt_rel set sid = 1328 where id = 113;
update zh_role_rpt_rel set sid = 1328 where id = 114;
update zh_role_rpt_rel set sid = 1328 where id = 115;
update zh_role_rpt_rel set sid = 1328 where id = 116;
update zh_role_rpt_rel set sid = 1329 where id = 107;
update zh_role_rpt_rel set sid = 1329 where id = 108;
update zh_role_rpt_rel set sid = 1329 where id = 109;
update zh_role_rpt_rel set sid = 1329 where id = 110;
update zh_role_rpt_rel set sid = 1329 where id = 111;
update zh_role_rpt_rel set sid = 1343 where id = 139;
update zh_role_rpt_rel set sid = 1344 where id = 124;
update zh_role_rpt_rel set sid = 1344 where id = 125;
update zh_role_rpt_rel set sid = 1344 where id = 126;
update zh_role_rpt_rel set sid = 1344 where id = 127;
update zh_role_rpt_rel set sid = 1344 where id = 128;
update zh_role_rpt_rel set sid = 1354 where id = 95;
update zh_role_rpt_rel set sid = 1354 where id = 96;
update zh_role_rpt_rel set sid = 1354 where id = 97;
update zh_role_rpt_rel set sid = 1354 where id = 98;
update zh_role_rpt_rel set sid = 1354 where id = 99;
update zh_role_rpt_rel set sid = 1361 where id = 93;
update zh_role_rpt_rel set sid = 1361 where id = 94;
update zh_role_rpt_rel set sid = 1367 where id = 100;
update zh_role_rpt_rel set sid = 1367 where id = 101;
update zh_role_rpt_rel set sid = 1367 where id = 102;
update zh_role_rpt_rel set sid = 1367 where id = 103;
update zh_role_rpt_rel set sid = 1367 where id = 104;
update zh_role_rpt_rel set sid = 1367 where id = 105;
update zh_role_rpt_rel set sid = 1367 where id = 106;
update zh_role_rpt_rel set sid = 1387 where id = 130;
update zh_role_rpt_rel set sid = 1553 where id = 140;
update zh_role_rpt_rel set sid = 1599 where id = 146;
update zh_role_rpt_rel set sid = 1599 where id = 148;
update zh_role_rpt_rel set sid = 1599 where id = 149;
update zh_role_rpt_rel set sid = 1599 where id = 150;
update zh_role_rpt_rel set sid = 1599 where id = 151;
update zh_role_rpt_rel set sid = 1603 where id = 147;
update zh_role_rpt_rel set sid = 1614 where id = 145;
update zh_role_rpt_rel set sid = 1620 where id = 142;
update zh_role_rpt_rel set sid = 1620 where id = 143;
update zh_role_rpt_rel set sid = 1620 where id = 144;
update zh_role_rpt_rel set sid = 1620 where id = 201;
update zh_role_rpt_rel set sid = 1620 where id = 202;
update zh_role_rpt_rel set sid = 1620 where id = 203;
update zh_role_rpt_rel set sid = 1620 where id = 204;
update zh_role_rpt_rel set sid = 1627 where id = 167;
update zh_role_rpt_rel set sid = 1627 where id = 168;
update zh_role_rpt_rel set sid = 1627 where id = 169;
update zh_role_rpt_rel set sid = 1627 where id = 170;
update zh_role_rpt_rel set sid = 1627 where id = 171;
update zh_role_rpt_rel set sid = 1629 where id = 188;
update zh_role_rpt_rel set sid = 1629 where id = 189;
update zh_role_rpt_rel set sid = 1676 where id = 152;
update zh_role_rpt_rel set sid = 1676 where id = 153;
update zh_role_rpt_rel set sid = 1676 where id = 154;
update zh_role_rpt_rel set sid = 1676 where id = 155;
update zh_role_rpt_rel set sid = 1676 where id = 156;
update zh_role_rpt_rel set sid = 1676 where id = 157;
update zh_role_rpt_rel set sid = 1794 where id = 175;
update zh_role_rpt_rel set sid = 1817 where id = 291;
update zh_role_rpt_rel set sid = 1820 where id = 200;
update zh_role_rpt_rel set sid = 1844 where id = 178;
update zh_role_rpt_rel set sid = 1846 where id = 280;
update zh_role_rpt_rel set sid = 1854 where id = 180;
update zh_role_rpt_rel set sid = 1879 where id = 195;
update zh_role_rpt_rel set sid = 1879 where id = 196;
update zh_role_rpt_rel set sid = 1879 where id = 197;
update zh_role_rpt_rel set sid = 1879 where id = 198;
update zh_role_rpt_rel set sid = 1879 where id = 199;
update zh_role_rpt_rel set sid = 1881 where id = 181;
update zh_role_rpt_rel set sid = 1881 where id = 182;
update zh_role_rpt_rel set sid = 1881 where id = 183;
update zh_role_rpt_rel set sid = 1881 where id = 184;
update zh_role_rpt_rel set sid = 1881 where id = 185;
update zh_role_rpt_rel set sid = 1881 where id = 186;
update zh_role_rpt_rel set sid = 1881 where id = 187;
update zh_role_rpt_rel set sid = 1930 where id = 292;
update zh_role_rpt_rel set sid = 1936 where id = 193;
update zh_role_rpt_rel set sid = 1945 where id = 194;
update zh_role_rpt_rel set sid = 2057 where id = 221;
update zh_role_rpt_rel set sid = 2057 where id = 222;
update zh_role_rpt_rel set sid = 2057 where id = 223;
update zh_role_rpt_rel set sid = 2057 where id = 224;
update zh_role_rpt_rel set sid = 2057 where id = 225;
update zh_role_rpt_rel set sid = 2058 where id = 242;
update zh_role_rpt_rel set sid = 2058 where id = 243;
update zh_role_rpt_rel set sid = 2058 where id = 244;
update zh_role_rpt_rel set sid = 2058 where id = 245;
update zh_role_rpt_rel set sid = 2058 where id = 246;
update zh_role_rpt_rel set sid = 2058 where id = 261;
update zh_role_rpt_rel set sid = 2062 where id = 248;
update zh_role_rpt_rel set sid = 2062 where id = 251;
update zh_role_rpt_rel set sid = 2062 where id = 254;
update zh_role_rpt_rel set sid = 2062 where id = 255;
update zh_role_rpt_rel set sid = 2062 where id = 256;
update zh_role_rpt_rel set sid = 2062 where id = 257;
update zh_role_rpt_rel set sid = 2064 where id = 233;
update zh_role_rpt_rel set sid = 2064 where id = 234;
update zh_role_rpt_rel set sid = 2064 where id = 235;
update zh_role_rpt_rel set sid = 2064 where id = 236;
update zh_role_rpt_rel set sid = 2064 where id = 237;
update zh_role_rpt_rel set sid = 2078 where id = 247;
update zh_role_rpt_rel set sid = 2078 where id = 249;
update zh_role_rpt_rel set sid = 2078 where id = 250;
update zh_role_rpt_rel set sid = 2078 where id = 252;
update zh_role_rpt_rel set sid = 2078 where id = 253;
update zh_role_rpt_rel set sid = 2092 where id = 258;
update zh_role_rpt_rel set sid = 2093 where id = 259;
update zh_role_rpt_rel set sid = 2093 where id = 260;
update zh_role_rpt_rel set sid = 2093 where id = 263;
update zh_role_rpt_rel set sid = 2102 where id = 265;
update zh_role_rpt_rel set sid = 2102 where id = 271;
update zh_role_rpt_rel set sid = 2102 where id = 289;
update zh_role_rpt_rel set sid = 2102 where id = 290;
update zh_role_rpt_rel set sid = 2109 where id = 266;
update zh_role_rpt_rel set sid = 2109 where id = 267;
update zh_role_rpt_rel set sid = 2119 where id = 269;
update zh_role_rpt_rel set sid = 2119 where id = 270;
update zh_role_rpt_rel set sid = 2119 where id = 278;
update zh_role_rpt_rel set sid = 2119 where id = 279;
update zh_role_rpt_rel set sid = 2127 where id = 272;
update zh_role_rpt_rel set sid = 2161 where id = 294;
update zh_role_rpt_rel set sid = 2161 where id = 295;
update zh_role_rpt_rel set sid = 2161 where id = 297;
update zh_role_rpt_rel set sid = 2177 where id = 293;
update zh_role_rpt_rel set sid = 2186 where id = 296;
update zh_role_rpt_rel set sid = 2187 where id = 288;


-- ----------------------------
-- Table structure for zh_maintain
-- ----------------------------
CREATE TABLE `zh_maintain` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `maintain_time` varchar(15) COLLATE utf8_unicode_ci NOT NULL COMMENT '维护时间',
  `duration` tinyint(4) NOT NULL DEFAULT '2' COMMENT '维护时长',
  `msg` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '维护内容',
  `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '维护状态，0：未设置，1：未开始，2：进行中',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='系统维护信息表';


INSERT INTO `zh_maintain` (`id`, `maintain_time`, `duration`, `msg`, `status`) VALUES
(1, '', 2, '', 0);

-- ----------------------------
-- zh_message add column 创建者id
-- ----------------------------
ALTER TABLE `zh_message`
ADD COLUMN `create_uid` int(11) DEFAULT NULL COMMENT '创建者id' AFTER `create_time`;

-- ----------------------------
-- zh_message add column 项目id
-- ----------------------------
ALTER TABLE `zh_message`
ADD COLUMN `project_id` int(11) DEFAULT NULL COMMENT '项目id，针对项目通知' AFTER `create_uid`;

-- ----------------------------
-- zh_message add column 是否置顶
-- ----------------------------
ALTER TABLE `zh_message`
ADD COLUMN `istop` varchar(15) NOT NULL DEFAULT '0' COMMENT '是否置顶，0为非置顶，时间戳为置顶时间' AFTER `release_time`;

-- ----------------------------
-- zh_message change column content
-- ----------------------------
ALTER TABLE `zh_message`
CHANGE `content` `content` text CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '消息内容';

-- ----------------------------
-- zh_message change column create_time
-- ----------------------------
ALTER TABLE `zh_message`
CHANGE `create_time` `create_time` varchar(15) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '创建时间';

-- ----------------------------
-- zh_message change column creator
-- ----------------------------
ALTER TABLE `zh_message`
CHANGE `creator` `creator` varchar(15) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '创建者';

-- ----------------------------
-- zh_message change column type
-- ----------------------------
ALTER TABLE `zh_message`
CHANGE `type` `type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '消息类型 1为项目 2为系统';

-- ----------------------------
-- zh_message change column status
-- ----------------------------
ALTER TABLE `zh_message`
CHANGE `status` `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '消息状态，1：已发布，2：未发布';

-- ----------------------------
-- zh_message change column release_time
-- ----------------------------
ALTER TABLE `zh_message`
CHANGE `release_time` `release_time` int(10) NOT NULL DEFAULT '0' COMMENT '发布时间';

-- ----------------------------
-- zh_project add column 是否定制项目
-- ----------------------------
ALTER TABLE `zh_project`
ADD COLUMN `custom` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否是定制项目' AFTER `dealpay_json`;

-- ----------------------------
-- zh_project add column 定制项目接口是否可用
-- ----------------------------
ALTER TABLE `zh_project`
ADD COLUMN `can_api` tinyint(1) NOT NULL DEFAULT '1' COMMENT '定制项目接口是否可用';

-- ----------------------------
-- zh_project add column 定制项目私钥
-- ----------------------------
ALTER TABLE `zh_project`
ADD COLUMN `secret` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '定制项目私钥';

-- ----------------------------
-- zh_project_account add column 是否已绑定定制项目
-- ----------------------------
ALTER TABLE `zh_project_account`
ADD COLUMN `bind` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否已绑定定制项目' AFTER `sms_type`;

-- ----------------------------
-- 权限控制表，新增部分权限
-- ----------------------------
INSERT INTO `calculation`.`zh_permission` (`id`, `name`, `controller`, `action`, `pid`, `icon_class`, `create_time`, `isshow`) VALUES ('67', '系统维护', 'maintain', '', '11', '', NULL, '1');
INSERT INTO `calculation`.`zh_permission` (`id`, `name`, `controller`, `action`, `pid`, `icon_class`, `create_time`, `isshow`) VALUES ('68', '第三方接口', 'project', 'api2other', '38', 'api2other', NULL, '1');
INSERT INTO `calculation`.`zh_permission` (`id`, `name`, `controller`, `action`, `pid`, `icon_class`, `create_time`, `isshow`) VALUES ('69', '第三方接口设置', 'project', 'api2otherSave', '38', '', NULL, '1');

update `calculation`.`zh_permission` set `name` = '消息通知', `isshow` = 1 where `id` = 31;
update `calculation`.`zh_permission` set `create_time` = '1' where `id` = 62;
