SET NAMES utf8;

SET FOREIGN_KEY_CHECKS = 0;
ALTER TABLE `t_statement_calculation` ADD COLUMN
IF
	NOT EXISTS `year` INT ( 1 ) NULL AFTER `calculation_collection_id`,
ADD COLUMN
IF
	NOT EXISTS `month` INT ( 1 ) NULL AFTER `year`,
ADD COLUMN
IF
	NOT EXISTS `day` INT ( 1 ) NULL AFTER `month`;
ALTER TABLE `t_tag_list` ADD COLUMN
IF
	NOT EXISTS `permission_view` INT ( 1 ) NULL DEFAULT 1 AFTER `position`;
UPDATE `t_tag_list`
SET `permission_view` = `permission`;
ALTER TABLE `t_tag_permission` ADD COLUMN
IF
	NOT EXISTS `allow` INT ( 1 ) NULL DEFAULT 1 AFTER `user_id`;

SET FOREIGN_KEY_CHECKS = 1;