Skip to content

Commit

Permalink
加入数据库sql文件
Browse files Browse the repository at this point in the history
加入数据库sql文件可直接导入数据表
  • Loading branch information
gmars committed Jun 27, 2018
1 parent f8197c8 commit 8c08cd5
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ composer require gmars/tp5-rbac
"gmars/tp5-rbac": "dev-master"
},
```
##数据迁移
##数据迁移(可选,可以直接使用包中的gmars_rbac.sql文件导入)
在使用本插件之前需要有rbac锁需要的数据库。在迁移之前如果你的数据库中已有user数据表那么请你备份自己的user数据表后删除。

在你的项目的某个config.php中加入如下配置:
Expand Down
109 changes: 109 additions & 0 deletions gmars_rbac.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
Navicat MySQL Data Transfer
Source Server : 本地数据库
Source Server Version : 50553
Source Host : localhost:3306
Source Database : gmars_rbac
Target Server Type : MYSQL
Target Server Version : 50553
File Encoding : 65001
Date: 2018-06-27 16:50:55
*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for permission
-- ----------------------------
DROP TABLE IF EXISTS `permission`;
CREATE TABLE `permission` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL DEFAULT '' COMMENT '权限节点名称',
`path` varchar(100) NOT NULL DEFAULT '' COMMENT '权限路径',
`path_id` varchar(100) NOT NULL DEFAULT '' COMMENT '路径唯一编码',
`description` varchar(200) NOT NULL DEFAULT '' COMMENT '描述信息',
`status` smallint(4) unsigned NOT NULL DEFAULT '0' COMMENT '状态0未启用1正常',
`create_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
PRIMARY KEY (`id`),
KEY `idx_permission` (`path_id`,`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='权限节点';

-- ----------------------------
-- Records of permission
-- ----------------------------

-- ----------------------------
-- Table structure for role
-- ----------------------------
DROP TABLE IF EXISTS `role`;
CREATE TABLE `role` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL DEFAULT '' COMMENT '角色名',
`parent_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '父级id(一般不建议角色的继承)',
`description` varchar(200) NOT NULL DEFAULT '' COMMENT '角色描述',
`status` smallint(4) unsigned NOT NULL DEFAULT '0' COMMENT '状态1正常0未启用',
`sort_num` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排序值',
`left_key` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '左值',
`right_key` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '右值',
`level` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '层级',
PRIMARY KEY (`id`),
KEY `idx_role` (`status`,`left_key`,`right_key`,`level`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色';

-- ----------------------------
-- Records of role
-- ----------------------------

-- ----------------------------
-- Table structure for role_permission
-- ----------------------------
DROP TABLE IF EXISTS `role_permission`;
CREATE TABLE `role_permission` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`role_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '角色编号',
`permission_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '权限编号',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色权限对应表';

-- ----------------------------
-- Records of role_permission
-- ----------------------------

-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`user_name` varchar(50) NOT NULL DEFAULT '' COMMENT '用户名',
`password` varchar(64) NOT NULL DEFAULT '' COMMENT '用户密码',
`mobile` varchar(20) NOT NULL DEFAULT '' COMMENT '手机号码',
`last_login_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最后一次登录时间',
`status` smallint(4) unsigned NOT NULL DEFAULT '0' COMMENT '状态0禁用1正常',
`create_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '账号创建时间',
`update_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '信息更新时间',
PRIMARY KEY (`id`),
KEY `idx_user` (`user_name`,`mobile`,`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表';

-- ----------------------------
-- Records of user
-- ----------------------------

-- ----------------------------
-- Table structure for user_role
-- ----------------------------
DROP TABLE IF EXISTS `user_role`;
CREATE TABLE `user_role` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
`role_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '角色id',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户角色对应关系';

-- ----------------------------
-- Records of user_role
-- ----------------------------

0 comments on commit 8c08cd5

Please sign in to comment.