-
Notifications
You must be signed in to change notification settings - Fork 33
/
rbac.sql
132 lines (118 loc) · 4.97 KB
/
rbac.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
Navicat MySQL Data Transfer
Source Server : localhost
Source Server Type : MySQL
Source Server Version : 50724
Source Host : localhost
Source Database : rbac
Target Server Type : MySQL
Target Server Version : 50724
File Encoding : utf-8
Date: 06/10/2019 14:03:59 PM
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for `menu`
-- ----------------------------
DROP TABLE IF EXISTS `menu`;
CREATE TABLE `menu` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL COMMENT '名称',
`pid` int(11) NOT NULL DEFAULT '0' COMMENT '父id',
`route` varchar(50) DEFAULT NULL COMMENT '路由',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COMMENT='菜单表';
-- ----------------------------
-- Records of `menu`
-- ----------------------------
BEGIN;
INSERT INTO `menu` VALUES ('1', '权限管理', '0', null, '2019-06-08 03:35:44', '2019-06-08 03:35:44'), ('2', '用户管理', '1', 'admin.user.index', '2019-06-08 03:36:00', '2019-06-08 03:36:00'), ('3', '角色管理', '1', 'admin.roles.index', '2019-06-08 03:36:20', '2019-06-08 03:36:20'), ('4', '权限组管理', '1', 'admin.permission.index', '2019-06-08 03:36:37', '2019-06-08 03:36:37'), ('5', '菜单管理', '1', 'admin.menu.index', '2019-06-08 03:37:12', '2019-06-08 03:37:12');
COMMIT;
-- ----------------------------
-- Table structure for `menu_roles`
-- ----------------------------
DROP TABLE IF EXISTS `menu_roles`;
CREATE TABLE `menu_roles` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`menu_id` int(11) NOT NULL,
`roles_id` int(11) NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='菜单-角色关系表';
-- ----------------------------
-- Table structure for `permission`
-- ----------------------------
DROP TABLE IF EXISTS `permission`;
CREATE TABLE `permission` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`routes` text COMMENT '路由别名,逗号分隔',
`name` varchar(50) NOT NULL COMMENT '名称',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='permission权限组';
-- ----------------------------
-- Table structure for `roles`
-- ----------------------------
DROP TABLE IF EXISTS `roles`;
CREATE TABLE `roles` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL COMMENT '角色名称',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色表';
-- ----------------------------
-- Table structure for `roles_permission`
-- ----------------------------
DROP TABLE IF EXISTS `roles_permission`;
CREATE TABLE `roles_permission` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`roles_id` int(10) unsigned NOT NULL COMMENT '角色id',
`permission_id` int(10) unsigned NOT NULL COMMENT '权限组id',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色-权限关系表';
-- ----------------------------
-- Table structure for `users`
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`email` varchar(50) NOT NULL COMMENT '邮箱',
`name` varchar(50) NOT NULL COMMENT '姓名',
`password` varchar(188) NOT NULL COMMENT '密码',
`administrator` tinyint(3) DEFAULT '2' COMMENT '是否超管,1是,2否',
`status` tinyint(3) DEFAULT '1' COMMENT '状态,1启用,2禁用',
`creator_id` int(11) DEFAULT NULL COMMENT '创建者id',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表';
-- ----------------------------
-- Records of `users`
-- ----------------------------
BEGIN;
INSERT INTO `users` VALUES ('1', 'admin@admin.com', '超级管理员', '$2y$10$QOtlXJ5mTdOJtOh9VVXGIekS2k2OzNdiMcq.F5Cnlr8CnWdq980ha', '1', '1', '1', '2019-05-05 19:57:01', '2019-06-10 03:29:56');
COMMIT;
-- ----------------------------
-- Table structure for `users_roles`
-- ----------------------------
DROP TABLE IF EXISTS `users_roles`;
CREATE TABLE `users_roles` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`users_id` int(10) unsigned NOT NULL COMMENT '用户id',
`roles_id` int(10) unsigned NOT NULL COMMENT '角色id',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户-角色关系表';
SET FOREIGN_KEY_CHECKS = 1;