sql.sql 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. create table sys_user
  2. (
  3. id bigint auto_increment primary key,
  4. username varchar(255) null,
  5. password varchar(255) not null,
  6. mobile_number varchar(15) null comment '手机',
  7. gender tinyint default '0' not null comment '性别',
  8. email varchar(50) null comment '邮箱',
  9. latest_login_time timestamp null comment '最后登录的时间',
  10. create_time datetime comment '创建时间',
  11. nickname varchar(100) comment '创建时间',
  12. avatar varchar(300) comment '创建时间',
  13. enable tinyint default 0 not null,
  14. type tinyint(2) default 2 null,
  15. openid varchar(200) null,
  16. constraint user_openId_uindex unique (openid)
  17. )
  18. comment '用户表' charset = utf8mb4;
  19. create table sys_role
  20. (
  21. id mediumint(8) auto_increment
  22. primary key,
  23. name varchar(255) not null,
  24. description varchar(100) null,
  25. constraint role_name_uindex
  26. unique (name)
  27. )
  28. comment '角色表' charset = utf8mb4;
  29. create table sys_power
  30. (
  31. id mediumint(8) auto_increment
  32. primary key,
  33. name varchar(255) not null,
  34. url varchar(255) not null,
  35. pid mediumint(8) null,
  36. constraint power_name_url_pk
  37. unique (name, url)
  38. )
  39. charset = utf8mb4;
  40. create table sys_user_role
  41. (
  42. role_id bigint not null,
  43. user_id bigint not null,
  44. primary key (role_id, user_id)
  45. )
  46. charset = utf8mb4;
  47. create index user_role_user_id_fk
  48. on sys_user_role (user_id);
  49. create table sys_role_power
  50. (
  51. role_id mediumint(8) not null,
  52. power_id mediumint(8) not null,
  53. primary key (role_id, power_id),
  54. constraint role_power_power_id_fk
  55. foreign key (power_id) references sys_power (id),
  56. constraint role_power_role_id_fk
  57. foreign key (role_id) references sys_role (id)
  58. )
  59. charset = utf8mb4;
  60. create table sys_whitelist
  61. (
  62. url varchar(100) not null
  63. primary key
  64. );