SET FOREIGN_KEY_CHECKS=0;

ALTER TABLE `bod_trade` ADD INDEX `tradeid_index`(`TradeId` ASC, `ValueDate` ASC) USING BTREE;

ALTER TABLE `clientcashincashout` ADD COLUMN `ApprovalProcess` int NOT NULL DEFAULT 0 COMMENT '审批进程，默认为0，已拒绝-1，已确认-2' AFTER `Deal`;

ALTER TABLE `clientcashincashout` MODIFY COLUMN `Money` double(18, 6) NULL DEFAULT NULL COMMENT '出入金额' AFTER `Action`;

ALTER TABLE `eod_pnl` MODIFY COLUMN `ActualPnL` double NULL DEFAULT NULL AFTER `UnrealizedPnL`;

ALTER TABLE `eod_pnl_extend` MODIFY COLUMN `ActualPnL` double NULL DEFAULT NULL AFTER `UnrealizedPnL`;

ALTER TABLE `eod_pnl_extend` MODIFY COLUMN `TotalPnl` double NOT NULL DEFAULT 0 COMMENT '总盈亏' AFTER `Strike`;

ALTER TABLE `eod_pnl_extend_s` MODIFY COLUMN `ActualPnL` double NULL DEFAULT NULL AFTER `UnrealizedPnL`;

ALTER TABLE `eod_pnl_extend_s` MODIFY COLUMN `TotalPnl` double NOT NULL DEFAULT 0 COMMENT '总盈亏' AFTER `Strike`;

ALTER TABLE `eod_pnl_hedgevol` MODIFY COLUMN `ActualPnL` double NULL DEFAULT NULL AFTER `UnrealizedPnL`;

ALTER TABLE `eod_pnl_hedgevol_s` MODIFY COLUMN `ActualPnL` double NULL DEFAULT NULL AFTER `UnrealizedPnL`;

ALTER TABLE `eod_pnl_openvol` MODIFY COLUMN `ActualPnL` double NULL DEFAULT NULL AFTER `UnrealizedPnL`;

ALTER TABLE `eod_pnl_openvol_s` MODIFY COLUMN `ActualPnL` double NULL DEFAULT NULL AFTER `UnrealizedPnL`;

ALTER TABLE `eod_pnl_openvol_s` MODIFY COLUMN `Cost` double NOT NULL DEFAULT 0 AFTER `UnderlyingCode`;

ALTER TABLE `eod_pnl_s` MODIFY COLUMN `ActualPnL` double NULL DEFAULT NULL AFTER `UnrealizedPnL`;

ALTER TABLE `eod_pnl_s` MODIFY COLUMN `Commission` double NOT NULL DEFAULT 0 AFTER `ExchangeOptionCode`;

CREATE TABLE `eod_scenarioanalysis`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `ValueDate` date NOT NULL COMMENT '计算日期',
  `TradeId` int NOT NULL COMMENT '场外交易Id',
  `PnL1` double(18, 8) NULL DEFAULT NULL COMMENT '跌20%盈亏',
  `PnL2` double(18, 8) NULL DEFAULT NULL COMMENT '涨20%盈亏',
  `PnL` double(18, 8) NULL DEFAULT NULL COMMENT '最大盈亏',
  `CalcDateTime` datetime NOT NULL COMMENT '计算时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '格林大华用' ROW_FORMAT = Dynamic;

ALTER TABLE `eod_trade_position_swap_mannual` ADD COLUMN `Strategy` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '策略 （套利/非套利）' AFTER `OptDate`;

CREATE TABLE `quotefile`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `QuoteSection` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '报价板块',
  `QuoteDate` datetime NOT NULL,
  `FileName` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文件名称',
  `FilePath` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文件路径',
  `Disclaimer` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '免责申明',
  `MJson` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'M1,M2…；从上传文件中读取',
  `OptId` int NOT NULL COMMENT '操作人id',
  `OptName` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作人',
  `OptTime` datetime NOT NULL COMMENT '操作时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

CREATE TABLE `quotefiledetail`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键自增',
  `QuoteFileId` bigint NOT NULL COMMENT '报价文件主键',
  `UnderlyingCode` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '证券代码',
  `UnderlyingName` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '证券名称',
  `DataJson` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT 'm1-m6数据',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

CREATE TABLE `supervise_undelrying`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `undelrying` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '标的代码',
  `undelrying_CFMMC` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '报送标的代码',
  `CreateTime` datetime NOT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

CREATE TABLE `task_event`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键Id',
  `EventType` int NOT NULL COMMENT '事件类型:0第三方数据推送事件',
  `EventArgs` varchar(512) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '事件参数',
  `Status` int NOT NULL COMMENT '状态:0 待执行 1 执行中 2 执行失败  执行成功会被删除',
  `ErrorMsg` varchar(512) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '执行失败时的错误信息',
  `OptId` int NULL DEFAULT NULL COMMENT '操作人',
  `OptName` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作人名称',
  `OptDate` date NULL DEFAULT NULL COMMENT '操作时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `querybyeventtype`(`EventType` ASC, `Status` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '定时任务事件' ROW_FORMAT = Dynamic;

ALTER TABLE `trade_action` MODIFY COLUMN `ActionType` int NOT NULL DEFAULT 0 COMMENT '操作类型' AFTER `ValueDate`;

ALTER TABLE `trade_action` MODIFY COLUMN `ActionFlag` int NOT NULL DEFAULT 0 COMMENT '操作标识(增加扩展性)' AFTER `ActionType`;

ALTER TABLE `trade_cash` ADD COLUMN `CreateTime` datetime NULL DEFAULT NULL COMMENT '创建时间' AFTER `UnwindMethod`;

ALTER TABLE `trade_span` ADD COLUMN `InitialMargin` double NULL DEFAULT NULL COMMENT '初始预付金 * 额外系数' AFTER `PVJsons`;

ALTER TABLE `trade_span` ADD COLUMN `Extensions` varchar(8000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '扩展字段，保存字典格式' AFTER `InitialMargin`;

CREATE TABLE `trademarketreportconfigure`  (
  `Id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `ClientId` int NULL DEFAULT NULL COMMENT '客户ID',
  `TemplateId` int NULL DEFAULT NULL COMMENT '模板ID',
  `Remarks` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `OptId` int NULL DEFAULT NULL COMMENT '操作人ID',
  `OptName` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作人名称',
  `OptDate` datetime NULL DEFAULT NULL COMMENT '操作时间',
  PRIMARY KEY (`Id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

alter table trade_asian_option add EnhancedPrice double(18,6) NOT NULL DEFAULT 0 COMMENT '增强价格';

SET FOREIGN_KEY_CHECKS=1;