update_20170214_1_to_20170305_1.sql 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*==============================================================*/
  2. /* DBMS name: MySQL 5.0 */
  3. /* Created on: 2017/3/5 20:19:29 */
  4. /*==============================================================*/
  5. drop table if exists tmp_upms_permission;
  6. rename table upms_permission to tmp_upms_permission;
  7. drop table if exists tmp_upms_system;
  8. rename table upms_system to tmp_upms_system;
  9. /*==============================================================*/
  10. /* Table: upms_permission */
  11. /*==============================================================*/
  12. create table upms_permission
  13. (
  14. permission_id int(10) unsigned not null auto_increment comment '编号',
  15. system_id int(10) unsigned not null comment '所属系统',
  16. pid int(10) comment '所属上级',
  17. name varchar(20) comment '名称',
  18. type tinyint(4) comment '类型(1:目录,2:菜单,3:按钮)',
  19. permission_value varchar(50) comment '权限值',
  20. uri varchar(100) comment '路径',
  21. icon varchar(50) comment '图标',
  22. status tinyint(4) comment '状态(0:禁止,1:正常)',
  23. ctime bigint(20) comment '创建时间',
  24. orders bigint(20) comment '排序',
  25. primary key (permission_id)
  26. );
  27. alter table upms_permission comment '权限';
  28. insert into upms_permission (permission_id, system_id, pid, name, type, permission_value, uri, icon, status, ctime, orders)
  29. select permission_id, system_id, pid, name, type, permission_value, uri, icon, status, ctime, orders
  30. from tmp_upms_permission;
  31. /*==============================================================*/
  32. /* Table: upms_system */
  33. /*==============================================================*/
  34. create table upms_system
  35. (
  36. system_id int(10) unsigned not null auto_increment comment '编号',
  37. icon varchar(50) comment '图标',
  38. banner varchar(50) comment '背景',
  39. theme varchar(50) comment '主题',
  40. basepath varchar(100) comment '根目录',
  41. status tinyint(4) comment '状态(-1:黑名单,1:正常)',
  42. name varchar(20) comment '系统名称',
  43. title varchar(20) comment '系统标题',
  44. description varchar(300) comment '系统描述',
  45. ctime bigint(20) comment '创建时间',
  46. orders bigint(20) comment '排序',
  47. primary key (system_id)
  48. );
  49. alter table upms_system comment '系统';
  50. insert into upms_system (system_id, icon, basepath, status, name, title, description, ctime, orders)
  51. select system_id, icon, basepath, status, name, title, description, ctime, orders
  52. from tmp_upms_system;
  53. alter table upms_permission add constraint FK_Reference_29 foreign key (system_id)
  54. references upms_system (system_id) on delete restrict on update restrict;
  55. alter table upms_role_permission add constraint FK_Reference_22 foreign key (permission_id)
  56. references upms_permission (permission_id) on delete restrict on update restrict;
  57. alter table upms_user_permission add constraint FK_Reference_25 foreign key (permission_id)
  58. references upms_permission (permission_id) on delete restrict on update restrict;