Skip to content

Commit

Permalink
创建表
Browse files Browse the repository at this point in the history
  • Loading branch information
windhoney committed Sep 22, 2017
1 parent f8e4d77 commit 2629a16
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 154 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@
]
],
```
* **创建所需要的表**
```
//用户表user和菜单表menu
yii migrate --migrationPath=@vendor/windhoney/yii2-rest-rbac/migrations
//rbac相关权限表
yii migrate --migrationPath=@yii/rbac/migrations/
//oauth2相关表
yii migrate --migrationPath=@vendor/filsh/yii2-oauth2-server/migrations
```

* **添加路由配置**

Expand Down
152 changes: 0 additions & 152 deletions migrations/m140501_075311_add_oauth2_server.php

This file was deleted.

3 changes: 1 addition & 2 deletions migrations/m140602_111327_create_menu_table.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php

use yii\db\Migration;
use wind\rest\components\Configs;

/**
Expand All @@ -9,7 +8,7 @@
* @author Misbahul D Munir <misbahuldmunir@gmail.com>
* @since 1.0
*/
class m140602_111327_create_menu_table extends Migration
class m140602_111327_create_menu_table extends \yii\db\Migration
{

/**
Expand Down
33 changes: 33 additions & 0 deletions migrations/schema-mssql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Database schema required by yii2-admin.
*
* @author Misbahul D Munir <misbahuldmunir@gmail.com>
* @since 2.5
*/

drop table if exists [menu];
drop table if exists [user];

create table [menu]
(
[id] int IDENTITY PRIMARY KEY,
[name] varchar(128),
[parent] int(11),
[route] varchar(256),
[order] int(11),
[data] text,
foreign key (parent) references [menu]([id]) ON DELETE SET NULL ON UPDATE CASCADE
);

create table [user]
(
[id] int IDENTITY PRIMARY KEY,
[username] varchar(32) NOT NULL,
[auth_key] varchar(32) NOT NULL,
[password_hash] varchar(256) NOT NULL,
[password_reset_token] varchar(256),
[email] varchar(256) NOT NULL,
[status] integer not null default 10,
[created_at] integer not null,
[updated_at] integer not null
);
33 changes: 33 additions & 0 deletions migrations/schema-mysql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Database schema required by yii2-admin.
*
* @author Misbahul D Munir <misbahuldmunir@gmail.com>
* @since 2.5
*/

drop table if exists `menu`;
drop table if exists `user` cascade;

create table `menu`
(
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` varchar(128),
`parent` int(11),
`route` varchar(256),
`order` int(11),
`data` blob,
foreign key (`parent`) references `menu`(`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

create table `user`
(
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`username` varchar(32) NOT NULL,
`auth_key` varchar(32) NOT NULL,
`password_hash` varchar(256) NOT NULL,
`password_reset_token` varchar(256),
`email` varchar(256) NOT NULL,
`status` integer not null default 10,
`created_at` integer not null,
`updated_at` integer not null
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
33 changes: 33 additions & 0 deletions migrations/schema-oci.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Database schema required by yii2-admin.
*
* @author Misbahul D Munir <misbahuldmunir@gmail.com>
* @since 2.5
*/

drop table if exists "menu";
drop table if exists "user";

create table "menu"
(
"id" NUMBER(10) NOT NULL PRIMARY KEY,
"name" varchar(128),
"parent" number(10),
"route" varchar(256),
"order" number(10),
"data" BYTEA,
foreign key (parent) references "menu"("id") ON DELETE SET NULL ON UPDATE CASCADE
);

create table "user"
(
"id" NUMBER(10) NOT NULL PRIMARY KEY,
"username" varchar(32) NOT NULL,
"auth_key" varchar(32) NOT NULL,
"password_hash" varchar(256) NOT NULL,
"password_reset_token" varchar(256),
"email" varchar(256) NOT NULL,
"status" integer not null default 10,
"created_at" number(10) not null,
"updated_at" number(10) not null
);
33 changes: 33 additions & 0 deletions migrations/schema-pgsql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Database schema required by yii2-admin.
*
* @author Misbahul D Munir <misbahuldmunir@gmail.com>
* @since 2.5
*/

drop table if exists "menu";
drop table if exists "user";

create table "menu"
(
"id" serial NOT NULL PRIMARY KEY,
"name" varchar(128),
"parent" integer,
"route" varchar(256),
"order" integer,
"data" bytea,
foreign key ("parent") references "menu"("id") ON DELETE SET NULL ON UPDATE CASCADE
);

create table "user"
(
"id" serial NOT NULL PRIMARY KEY,
"username" varchar(32) NOT NULL,
"auth_key" varchar(32) NOT NULL,
"password_hash" varchar(256) NOT NULL,
"password_reset_token" varchar(256),
"email" varchar(256) NOT NULL,
"status" integer not null default 10,
"created_at" integer not null,
"updated_at" integer not null
);
33 changes: 33 additions & 0 deletions migrations/schema-sqlite.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Database schema required by yii2-admin.
*
* @author Misbahul D Munir <misbahuldmunir@gmail.com>
* @since 2.5
*/

drop table if exists "menu";
drop table if exists "user";

create table "menu"
(
"id" integer PRIMARY KEY AUTOINCREMENT NOT NULL,
"name" varchar(128),
"parent" int(11),
"route" varchar(256),
"order" int(11),
"data" LONGBLOB,
foreign key ("parent") references "menu"("id") ON DELETE SET NULL ON UPDATE CASCADE
);

create table "user"
(
"id" integer PRIMARY KEY AUTOINCREMENT NOT NULL,
"username" varchar(32) NOT NULL,
"auth_key" varchar(32) NOT NULL,
"password_hash" varchar(256) NOT NULL,
"password_reset_token" varchar(256),
"email" varchar(256) NOT NULL,
"status" integer not null default 10,
"created_at" integer not null,
"updated_at" integer not null
);

0 comments on commit 2629a16

Please sign in to comment.