repair_lite.sql 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*==============================================================*/
  2. /* DBMS name: MySQL 5.0 */
  3. /* Created on: 2019/3/15 16:42:14 */
  4. /*==============================================================*/
  5. drop table if exists action_bars;
  6. drop table if exists group_users;
  7. drop table if exists groups;
  8. drop table if exists roles;
  9. drop table if exists user_action_bars;
  10. drop table if exists user_roles;
  11. drop table if exists users;
  12. /*==============================================================*/
  13. /* Table: action_bars */
  14. /*==============================================================*/
  15. create table action_bars
  16. (
  17. id int not null auto_increment,
  18. parent int default 0 comment '该层菜单的上级菜单,第一层的上级菜单是0',
  19. name varchar(128),
  20. description varchar(255),
  21. icon varchar(255),
  22. link_type char(32) comment '定义link的含义,可以是跳转,可以是发起请求',
  23. link char(255),
  24. status char(32) default 'normal' comment '状态表,可能用户编辑了这个菜单,但是没有编辑完,所以只是存了一份草稿',
  25. created_at timestamp default CURRENT_TIMESTAMP,
  26. updated_at timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  27. created_user_id int,
  28. updated_user_id int,
  29. is_del bool default false,
  30. primary key (id)
  31. );
  32. alter table action_bars comment '下拉菜单';
  33. /*==============================================================*/
  34. /* Table: group_users */
  35. /*==============================================================*/
  36. create table group_users
  37. (
  38. id int not null auto_increment,
  39. group_id int,
  40. user_id int,
  41. status char(32) default 'normal',
  42. created_at timestamp default CURRENT_TIMESTAMP,
  43. updated_at timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  44. created_user_id int,
  45. updated_user_id int,
  46. is_del bool default false,
  47. primary key (id)
  48. );
  49. alter table group_users comment '用户组和用户的关联表';
  50. /*==============================================================*/
  51. /* Table: groups */
  52. /*==============================================================*/
  53. create table groups
  54. (
  55. id int not null auto_increment,
  56. name varchar(128),
  57. description varchar(255),
  58. icon varchar(255),
  59. status char(32) default 'normal',
  60. created_at timestamp default CURRENT_TIMESTAMP,
  61. updated_at timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  62. created_user_id int,
  63. updated_user_id int,
  64. is_del bool default false,
  65. primary key (id)
  66. );
  67. alter table groups comment '用户组';
  68. /*==============================================================*/
  69. /* Table: roles */
  70. /*==============================================================*/
  71. create table roles
  72. (
  73. id int not null auto_increment,
  74. name varchar(128) comment '角色的名字',
  75. description varchar(255) comment '角色的描述',
  76. status char(32) comment '状态信息',
  77. created_at timestamp default CURRENT_TIMESTAMP,
  78. updated_at timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  79. created_user_at int,
  80. updated_user_at int,
  81. is_del bool default false,
  82. primary key (id)
  83. );
  84. alter table roles comment '用户角色表';
  85. /*==============================================================*/
  86. /* Table: user_action_bars */
  87. /*==============================================================*/
  88. create table user_action_bars
  89. (
  90. id int not null auto_increment,
  91. owner_type char(16) default 'user' comment '拥有者的类型,值: user/group/role',
  92. owner_id int,
  93. bar_id int comment 'action bar的id',
  94. status char(32) default 'normal' comment '状态信息,比如角色是否生效的状态',
  95. created_at timestamp default CURRENT_TIMESTAMP comment '创建时间',
  96. updated_at timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '最后更新时间',
  97. created_user_id int,
  98. updated_user_id int,
  99. is_del bool default false comment '删除标志',
  100. primary key (id)
  101. );
  102. alter table user_action_bars comment '下拉菜单权限表';
  103. /*==============================================================*/
  104. /* Table: user_roles */
  105. /*==============================================================*/
  106. create table user_roles
  107. (
  108. id int not null auto_increment comment '用户id',
  109. user_id int,
  110. role_id int comment '用户角色id',
  111. status char(32) default 'normal',
  112. created_at timestamp default CURRENT_TIMESTAMP,
  113. updated_at timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  114. created_user_id int,
  115. updated_user_id int,
  116. is_del bool default false,
  117. primary key (id)
  118. );
  119. alter table user_roles comment '用户权限表';
  120. /*==============================================================*/
  121. /* Table: users */
  122. /*==============================================================*/
  123. create table users
  124. (
  125. id int not null auto_increment,
  126. username varchar(128) not null comment '用户名',
  127. password varchar(128) not null comment '用户密码',
  128. nickname varchar(255) comment '用户昵称',
  129. icon varchar(255),
  130. tel char(16) comment '用户电话',
  131. email char(64) comment '用户邮箱',
  132. created_at timestamp default CURRENT_TIMESTAMP comment '创建时间',
  133. updated_at timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '最后更新时间',
  134. created_user_id int,
  135. updated_user_id int,
  136. is_del bool default false comment '删除标志',
  137. primary key (id)
  138. );
  139. alter table users comment '用户表';