ALTER TABLE `oa_attendstat` ADD `paid` decimal(12,2) UNSIGNED NOT NULL AFTER `actual`;
ALTER TABLE `oa_todo` ADD `cycle` tinyint(3) UNSIGNED NOT NULL AFTER `type`;
ALTER TABLE `oa_todo` ADD `config` varchar(255) NOT NULL AFTER `private`;

ALTER TABLE `oa_leave` ADD `reviewers` text NOT NULL;
ALTER TABLE `oa_lieu` ADD `reviewers` text NOT NULL;
ALTER TABLE `oa_overtime` ADD `reviewers` text NOT NULL;

ALTER TABLE `sys_exchange` CHANGE `giftID` `gift` mediumint(8) unsigned NOT NULL;
ALTER TABLE `sys_exchange` CHANGE `canceledBy` `cancelledBy` varchar(30) NOT NULL;
ALTER TABLE `sys_exchange` CHANGE `canceledDate` `cancelledDate` datetime NOT NULL;
ALTER TABLE `sys_exchange` CHANGE `cancelReason` `cancelledReason` text NOT NULL;
ALTER TABLE `sys_exchange` MODIFY `status` varchar(10) NOT NULL DEFAULT 'normal';

UPDATE `sys_exchange` SET `status` = 'cancelled' WHERE `status` = 'canceled';
UPDATE `oa_leave` SET `start` = '08:20:00' , `finish` = '17:20:00' WHERE `type` = 'annual' AND `year` = '2022' AND `start` = '00:00:00' AND `finish` = '24:00:00';
UPDATE `sys_cron` SET `command` = 'appName=oa&moduleName=annual&methodName=giveAnnualLeave' WHERE `command` = 'appName=oa&moduleName=leave&methodName=giveAnnualLeave';

INSERT INTO `sys_cron` (`m`, `h`, `dom`, `mon`, `dow`, `command`, `remark`, `type`, `buildin`, `status`) VALUES ('1', '1', '*', '*', '*', 'appName=sys&moduleName=todo&methodName=createCycle', '生成周期性待办', 'zdoo', 1, 'normal');

INSERT INTO `sys_grouppriv` (`group`, `module`, `method`) SELECT `group`, 'exchange', 'my' FROM `sys_grouppriv` WHERE `module` = 'gift' AND `method` = 'myExchange';
INSERT INTO `sys_grouppriv` (`group`, `module`, `method`) SELECT `group`, 'exchange', 'toGrant' FROM `sys_grouppriv` WHERE `module` = 'gift' AND `method` = 'toGrant';
INSERT INTO `sys_grouppriv` (`group`, `module`, `method`) SELECT `group`, 'exchange', 'all' FROM `sys_grouppriv` WHERE `module` = 'gift' AND `method` = 'allExchange';
INSERT INTO `sys_grouppriv` (`group`, `module`, `method`) SELECT `group`, 'exchange', 'create' FROM `sys_grouppriv` WHERE `module` = 'gift' AND `method` = 'exchange';
INSERT INTO `sys_grouppriv` (`group`, `module`, `method`) SELECT `group`, 'exchange', 'grant' FROM `sys_grouppriv` WHERE `module` = 'gift' AND `method` = 'grant';
INSERT INTO `sys_grouppriv` (`group`, `module`, `method`) SELECT `group`, 'exchange', 'cancel' FROM `sys_grouppriv` WHERE `module` = 'gift' AND `method` = 'cancel';
INSERT INTO `sys_grouppriv` (`group`, `module`, `method`) SELECT `group`, 'exchange', 'finish' FROM `sys_grouppriv` WHERE `module` = 'gift' AND `method` = 'finish';

INSERT INTO `sys_grouppriv` (`group`, `module`, `method`) SELECT `group`, 'annual', 'all' FROM `sys_grouppriv` WHERE `module` = 'leave' AND `method` = 'allAnnual';

INSERT INTO `sys_grouppriv` (`group`, `module`, `method`) SELECT `group`, 'conversion', 'all' FROM `sys_grouppriv` WHERE `module` = 'leave' AND `method` = 'browseConversionReview';
INSERT INTO `sys_grouppriv` (`group`, `module`, `method`) SELECT `group`, 'conversion', 'review' FROM `sys_grouppriv` WHERE `module` = 'leave' AND `method` = 'reviewConversion';
INSERT INTO `sys_grouppriv` (`group`, `module`, `method`) SELECT `group`, 'conversion', 'grant' FROM `sys_grouppriv` WHERE `module` = 'leave' AND `method` = 'grantConversion';

RENAME TABLE `oa_annualconversion` TO `oa_conversion`;

CREATE TABLE IF NOT EXISTS `oa_attendgroup` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(30) NOT NULL,
  `signInLimit` char(10) NOT NULL,
  `signOutLimit` char(10) NOT NULL,
  `lunchBegin` char(10) NOT NULL,
  `lunchEnd` char(10) NOT NULL,
  `dinnerBegin` char(10) NOT NULL,
  `dinnerEnd` char(10) NOT NULL,
  `users` text NOT NULL,
  `createdBy` varchar(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` varchar(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  `deleted` enum('0', '1') NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `oa_annual` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `year` char(4) NOT NULL,
  `account` varchar(30) NOT NULL,
  `days` smallint(5) NOT NULL,
  `times` smallint(5) NOT NULL,
  `balance` smallint(5) NOT NULL,
  `createdBy` varchar(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` varchar(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `account` (`account`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
