 DROP INDEX `role_managerid`,
 ADD INDEX `inx_role_manage_id`(`manager_id`) USING BTREE;
 
-ALTER TABLE `role_model`
-CHANGE COLUMN `rm_modelid` `model_id` int(22) NULL DEFAULT NULL COMMENT '模块编号' FIRST,
-CHANGE COLUMN `rm_roleid` `role_id` int(22) NULL DEFAULT NULL COMMENT '角色编号' AFTER `model_id`;
-ALTER TABLE `role_model` DROP FOREIGN KEY `role_model_ibfk_1`;
-
-ALTER TABLE `role_model` DROP FOREIGN KEY `role_model_ibfk_2`;
-
-ALTER TABLE `role_model`
-ADD CONSTRAINT `fk_rm_role_id` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
-ADD CONSTRAINT `fk_rm_model_id` FOREIGN KEY (`model_id`) REFERENCES `model` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;
-
-ALTER TABLE `role_model`
-RENAME INDEX `rm_modelid` TO `fk_model_id`,
-RENAME INDEX `fk_role_model_role_1` TO `fk_role_id`,
-DROP INDEX `index`;
-
 ALTER TABLE `model`
 CHANGE COLUMN `model_modelid` `model_id` int(22) NULL DEFAULT NULL COMMENT '模块的父模块id' AFTER `model_code`,
 CHANGE COLUMN `model_modelmanagerid` `manager_id` int(11) NULL DEFAULT NULL COMMENT '模块关联的关联员id' AFTER `model_icon`;

ALTER TABLE `people_user`
RENAME INDEX `pu_people_id` TO `inx_people_id`;


ALTER TABLE `system_log`
DROP COLUMN `app_id`;



DROP TABLE IF EXISTS `system_log`;

DROP INDEX `model_code`,
ADD CONSTRAINT `fk_model_id` FOREIGN KEY (`model_id`) REFERENCES `model` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;

# 原来有数据可能会导致外键加不上
ALTER TABLE `role_model`
CHANGE COLUMN `rm_modelid` `model_id` int(22) NULL DEFAULT NULL COMMENT '模块编号' FIRST,
CHANGE COLUMN `rm_roleid` `role_id` int(22) NULL DEFAULT NULL COMMENT '角色编号' AFTER `model_id`;

ALTER TABLE `role_model`
RENAME INDEX `rm_modelid` TO `fk_model_id`,
RENAME INDEX `fk_role_model_role_1` TO `fk_role_id`,
DROP INDEX `index`;

ALTER TABLE `role_model` DROP FOREIGN KEY `role_model_ibfk_1`;

ALTER TABLE `role_model` DROP FOREIGN KEY `role_model_ibfk_2`;

ALTER TABLE `role_model`
ADD CONSTRAINT `fk_rm_role_id` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_rm_model_id` FOREIGN KEY (`model_id`) REFERENCES `model` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;




ALTER TABLE `manager` DROP FOREIGN KEY `manager_ibfk_1`;

