CREATE TABLE `zh_change_project_history` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tid` int(11) NOT NULL COMMENT '标段id',
  `cpid` int(11) NOT NULL COMMENT '变更立项id',
  `info_json` json DEFAULT NULL COMMENT '内容json值',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='变更立项内容临时保存表，用于修订撤销与撤回';

CREATE TABLE `zh_change_apply_history` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tid` int(11) NOT NULL COMMENT '标段id',
  `caid` int(11) NOT NULL COMMENT '变更申请id',
  `info_json` json DEFAULT NULL COMMENT '内容json值',
  `list_json` json DEFAULT NULL COMMENT '清单json值',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='变更申请内容临时保存表，用于修订撤销与撤回';

CREATE TABLE `zh_change_plan_history` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tid` int(11) NOT NULL COMMENT '标段id',
  `cpid` int(11) NOT NULL COMMENT '变更方案id',
  `info_json` json DEFAULT NULL COMMENT '内容json值',
  `list_json` json DEFAULT NULL COMMENT '清单json值',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='变更方案内容临时保存表，用于修订撤销与撤回';

ALTER TABLE `zh_ledger_tag`
ADD COLUMN `settle_id`  int(11) NOT NULL DEFAULT -1 AFTER `sorder`,
ADD COLUMN `settle_order`  tinyint(4) NOT NULL DEFAULT -1 AFTER `settle_id`;

ALTER TABLE `zh_ledger_attachment`
ADD COLUMN `settle_id`  int(11) NOT NULL DEFAULT -1 COMMENT '结算id' AFTER `tid`,
ADD COLUMN `settle_order`  tinyint(4) NOT NULL DEFAULT -1 COMMENT '结算期序号' AFTER `settle_id`;

ALTER TABLE `zh_s2b_spec_msg`
ADD COLUMN `advance_id`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '预付款期id' AFTER `rid`,
ADD COLUMN `material_id`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '材差期id' AFTER `advance_id`,
ADD COLUMN `c_apply_id`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '变更申请id' AFTER `material_id`,
ADD COLUMN `c_proj_id`  int(11) UNSIGNED NOT NULL COMMENT '变更立项id' AFTER `c_apply_id`,
ADD COLUMN `c_plan_id`  int(11) UNSIGNED NOT NULL COMMENT '变更方案id' AFTER `c_proj_id`,
ADD COLUMN `extra_info`  varchar(1000) NOT NULL DEFAULT '' COMMENT '附加信息（主要用于报表）' AFTER `timing`;
