ALTER TABLE `zh_pos_0`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_1`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_2`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_3`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_4`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_5`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_6`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_7`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_8`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_9`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_10`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_11`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_12`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_13`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_14`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_15`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_16`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_17`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_18`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_19`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

Update zh_pos_0 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_1 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_2 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_3 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_4 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_5 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_6 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_7 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_8 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_9 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_10 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_11 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_12 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_13 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_14 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_15 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_16 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_17 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_18 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_19 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;

ALTER TABLE `zh_revise_pos_0`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_1`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_2`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_3`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_4`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_5`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_6`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_7`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_8`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_9`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_10`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_11`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_12`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_13`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_14`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_15`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_16`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_17`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_18`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_19`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

Update zh_revise_pos_0 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_1 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_2 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_3 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_4 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_5 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_6 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_7 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_8 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_9 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_10 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_11 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_12 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_13 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_14 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_15 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_16 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_17 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_18 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_19 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;

CREATE TABLE `zh_change_revise_log`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tid` int(11) NOT NULL,
  `cid` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '变更令id',
  `lid` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '插入的清单uuid',
  `pid` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '插入的计量单元uuid',
  `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '清单名称或计量单元编号',
  `create_time` datetime NOT NULL COMMENT '入库时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '变更新增部位记录表';

ALTER TABLE `zh_change_pos`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

Update zh_change_pos p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;

ALTER TABLE `zh_tender`
ADD COLUMN `bills_file`  varchar(255) NOT NULL DEFAULT '' COMMENT '台账-清单文件' AFTER `has_rela`,
ADD COLUMN `pos_file`  varchar(255) NOT NULL DEFAULT '' COMMENT '台账-计量单元文件' AFTER `bills_file`;

CREATE TABLE `zh_material_checklist`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tid` int(11) NOT NULL COMMENT '标段id',
  `mid` int(11) NOT NULL COMMENT '调差期id',
  `b_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '清单编号',
  `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '清单名称',
  `unit` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '单位',
  `unit_price` decimal(30, 8) NOT NULL COMMENT '单价',
  `quantity` decimal(30, 8) NOT NULL COMMENT '数量（工程量）',
  `total_price` decimal(30, 8) NOT NULL COMMENT '金额',
  `had_bills` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否已添加工料',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '默认清单设置功能';

CREATE TABLE `zh_ledger_history` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `pid` bigint(20) unsigned NOT NULL COMMENT '项目id',
  `tid` bigint(20) unsigned NOT NULL COMMENT '标段id',
  `rid` varchar(36) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '修订id',
  `rorder` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '修订序号',
  `cid` varchar(36) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '工程变更id',
  `in_time` datetime NOT NULL,
  `bills_file` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '项目节数据文件',
  `pos_file` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '计量单元数据文件',
  `valid`  tinyint(4) UNSIGNED NOT NULL DEFAULT 1 COMMENT '是否有效',
  PRIMARY KEY (`id`),
  KEY `idx_tid_valid_time` (`tid`,`valid`,`in_time`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

ALTER TABLE `zh_ledger_revise`
ADD COLUMN `his_id`  bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '修订后，台账历史数据id' AFTER `content`,
ADD COLUMN `pre_his_id`  bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '修订前，台账历史数据id' AFTER `his_id`;

ALTER TABLE `zh_tender`
ADD COLUMN `his_id`  bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '台账历史数据id' AFTER `s2b_dagl_limit`;

ALTER TABLE `zh_stage`
ADD COLUMN `his_id`  bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '历史台账id' AFTER `tp_history`;

ALTER TABLE `zh_stage_pay`
ADD COLUMN `postil`  varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '本期批注' AFTER `start_stage_order`;

ALTER TABLE `zh_tender` ADD `c_code_rules` TEXT NULL DEFAULT NULL COMMENT '变更立项及申请的编号规则json' AFTER `c_rule_first`;

CREATE TABLE `zh_change_project`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tid` int(11) NOT NULL COMMENT '标段id',
  `uid` int(11) NOT NULL COMMENT '发起人',
  `code` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '立项书编号',
  `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '立项书名称',
  `in_time` datetime NOT NULL COMMENT '发起时间',
  `status` tinyint(2) NOT NULL COMMENT '立项状态',
  `times` tinyint(2) NOT NULL COMMENT '审批次数',
  `type` tinyint(1) NOT NULL COMMENT '立项书类型',
  `org_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '原设计图名称',
  `peg` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '桩号',
  `new_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '图号',
  `class` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '变更类别',
  `quality` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '变更性质',
  `org_price` decimal(30, 8) NULL DEFAULT NULL COMMENT '原工程造价(元)',
  `change_price` decimal(30, 8) NULL DEFAULT NULL COMMENT '预计变更造价(元)',
  `crease_price` decimal(30, 8) NULL DEFAULT NULL COMMENT '预计造价增减(元)',
  `reason` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '变更原因',
  `content` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '内容摘要',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '变更立项表';

CREATE TABLE `zh_change_project_attachment`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tid` int(11) NOT NULL COMMENT '标段id',
  `cpid` int(11) NOT NULL COMMENT '立项id',
  `uid` int(11) NOT NULL COMMENT '上传者id',
  `filename` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '文件名称',
  `fileext` varchar(5) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '文件后缀',
  `filesize` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '文件大小',
  `filepath` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '文件存储路径',
  `upload_time` datetime NOT NULL COMMENT '上传时间',
  `extra_upload` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否为审核通过后再次上传的文件，0为否',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_cid`(`cpid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '变更立项附件表';

CREATE TABLE `zh_change_project_audit`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `tid` int(11) NOT NULL COMMENT '标段id',
  `cpid` int(11) NOT NULL COMMENT '立项id',
  `aid` int(11) NOT NULL COMMENT '审批人id',
  `order` int(11) NOT NULL COMMENT '审批顺序',
  `times` int(11) NOT NULL COMMENT '审批次数',
  `status` tinyint(1) NOT NULL COMMENT '审批状态',
  `begin_time` datetime NULL DEFAULT NULL COMMENT '开始审批时间',
  `end_time` datetime NULL DEFAULT NULL COMMENT '结束审批时间',
  `opinion` varchar(1000) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '审批意见',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '变更立项审批表';

UPDATE `zh_ledger_revise` SET bills_file = replace(bills_file, '/revise', 'revise') WHERE not ISNULL(bills_file);
UPDATE `zh_ledger_revise` SET pos_file = replace(pos_file, '/revise', 'revise') WHERE not ISNULL(pos_file);

ALTER TABLE `zh_material_checklist` CHANGE `unit_price` `unit_price` DECIMAL(30,8) NULL DEFAULT NULL COMMENT '单价';
ALTER TABLE `zh_material_checklist` CHANGE `quantity` `quantity` DECIMAL(30,8) NULL DEFAULT NULL COMMENT '数量（工程量）';
ALTER TABLE `zh_material_checklist` CHANGE `total_price` `total_price` DECIMAL(30,8) NULL DEFAULT NULL COMMENT '金额';

ALTER TABLE `zh_change` ADD `up_decimal` TINYINT(2) NULL DEFAULT NULL COMMENT '数量小数位数' AFTER `tp_decimal`;

ALTER TABLE `zh_rpt_custom_define`
ADD COLUMN `material_sum_select`  text CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '用户定制信息 - 材差 - 多期汇总表' AFTER `stage_select`;

ALTER TABLE `zh_change`
ADD COLUMN `selected`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '报表用，是否选择' AFTER `tid`;

ALTER TABLE `zh_change_project`
ADD COLUMN `selected`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '报表用，是否选择' AFTER `tid`;

ALTER TABLE `zh_change_apply`
ADD COLUMN `selected`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '报表用，是否选择' AFTER `tid`;

