-- 2020-06-08 lingpj 添加两个常用脚本: 获取当前年份,获取当前月份
INSERT INTO BPM_SCRIPT(ID_, NAME_, SCRIPT_, CATEGORY_, MEMO_, CREATE_TIME_, CREATE_BY_, CREATE_ORG_ID_, UPDATE_BY_, UPDATE_TIME_, TENANT_ID_) VALUES ('1269805454708576256', '获取当前年份', 'return scriptImpl.getCurrentYear();', '系统脚本', '获取当前年份，例如"2020"', NULL, '1', '', NULL, NULL, '-1');
INSERT INTO BPM_SCRIPT(ID_, NAME_, SCRIPT_, CATEGORY_, MEMO_, CREATE_TIME_, CREATE_BY_, CREATE_ORG_ID_, UPDATE_BY_, UPDATE_TIME_, TENANT_ID_) VALUES ('1269805555023745024', '获取当前月份', 'return scriptImpl.getCurrentMonth();', '系统脚本', '获取当前月份，例如"06"', NULL, '1', '', NULL, NULL, '-1');

-- 2020-06-08 heyf 添加一个基础服务的日志配置，避免在以assembly启动时找不到对应的配置反复加载日志配置。
INSERT INTO PORTAL_SYS_LOGS_SETTINGS(ID_, MODULE_TYPE_, STATUS_, SAVE_DAYS_, REMARK_, TENANT_ID_) VALUES ('6', 'base', '1', '180', '默认服务', '-1');

-- 2020-06-08 lingpj 租户是否删除添加默认值
UPDATE UC_TENANT_MANAGE SET IS_DELE_ = 0 WHERE IS_DELE_ IS NULL;

-- 2020-06-09 lingpj 修改表单元数据的唯一索引条件，以免不用租户无法添加相同别名的表单
ALTER TABLE FORM_META
DROP INDEX IDX_FORMMETA;
CREATE UNIQUE INDEX IDX_FORMMETA ON FORM_META (KEY_,TENANT_ID_);

-- 2020-06-09 heyf 用户角色关系表中，添加两个索引
ALTER TABLE `uc_user_role`
ADD INDEX `IDX_USER_ROLE_USERID` (`USER_ID_`) ,
ADD INDEX `IDX_USER_ROLE_ROLEID` (`ROLE_ID_`) ;

-- 2020-06-09 heyf 组织表中，parent_id_添加为索引
ALTER TABLE `uc_org`
ADD INDEX `IDX_ORG_PARENTID` (`PARENT_ID_`) ;

-- 2020-06-13 pangq 添加 应用端我的报表草稿 菜单
INSERT INTO `portal_sys_menu`(`ID_`, `PARENT_ID_`, `NAME_`, `ALIAS_`, `ACTIVE_TAB_`, `MENU_ICON_`, `OPENED_`, `SN_`, `TABS_STYLE_`, `PATH_`, `HREF_`, `TENANT_ID_`) VALUES ('1271725674687762432', '1270612914549690368', '报表草稿', 'draftList', '', '', 1, 1, '', '-1.3.1270612914549690368.1271725674687762432.', '', '-1');

-- 2020-06-13 pangq 添加 数据报表草稿数据 表
CREATE TABLE `form_data_template_draft` (
  `ID_` varchar(64) NOT NULL COMMENT '主键',
  `TITLE_` varchar(255) DEFAULT NULL COMMENT '标题',
  `TEMP_ALIAS_` varchar(64) DEFAULT NULL COMMENT '数据报表别名',
  `DATA_JSON_` text COMMENT '报表数据json',
  `CREATE_BY_` varchar(64) DEFAULT NULL COMMENT '创建人',
  `CREATE_TIME_` datetime DEFAULT NULL COMMENT '创建时间',
  `tenant_id_` varchar(64) DEFAULT NULL COMMENT '租户id',
  PRIMARY KEY (`ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='数据报表草稿数据';

-- 2020-06-16 lingpj 去掉报表中心菜单及相关菜单授权
DELETE FROM PORTAL_SYS_MENU WHERE ID_ = '13541819';
DELETE FROM PORTAL_SYS_ROLE_AUTH WHERE ID_ = '1259058943339139072';
DELETE FROM PORTAL_SYS_ROLE_AUTH WHERE ID_ = '1259058898460086272';
DELETE FROM PORTAL_SYS_ROLE_AUTH WHERE ID_ = '1259058869624246272';

-- 2020-06-19 lingpj 调整重复索引名
ALTER TABLE BPM_CHECK_OPINION
DROP INDEX IDX_OPINION_SUPINSTID;
CREATE INDEX IDX_CHECKOPINION_SUPINSTID ON BPM_CHECK_OPINION (SUP_INST_ID_);

-- 补充，前期版本更新增加应用中心菜单
INSERT INTO `mydemo_saas`.`portal_sys_menu`(`ID_`, `PARENT_ID_`, `NAME_`, `ALIAS_`, `ACTIVE_TAB_`, `MENU_ICON_`, `OPENED_`, `SN_`, `TABS_STYLE_`, `PATH_`, `HREF_`, `TENANT_ID_`) VALUES ('4', '-1', '应用分类菜单', 'app_menu', '', '', 1, 3, '{\"tabType\":\"border-card\"}', '-1.4.', NULL, '-1');
