yii2
60 строк · 1.8 Кб
1/**
2* Database schema required by \yii\rbac\DbManager.
3*
4* @author Qiang Xue <qiang.xue@gmail.com>
5* @author Alexander Kochetov <creocoder@gmail.com>
6* @link https://www.yiiframework.com/
7* @copyright 2008 Yii Software LLC
8* @license https://www.yiiframework.com/license/
9* @since 2.0
10*/
11
12drop table "auth_assignment";
13drop table "auth_item_child";
14drop table "auth_item";
15drop table "auth_rule";
16
17-- create new auth_rule table
18create table "auth_rule"
19(
20"name" varchar(64) not null,
21"data" BYTEA,
22"created_at" integer,
23"updated_at" integer,
24primary key ("name")
25);
26
27-- create auth_item table
28create table "auth_item"
29(
30"name" varchar(64) not null,
31"type" smallint not null,
32"description" varchar(1000),
33"rule_name" varchar(64),
34"data" BYTEA,
35"updated_at" integer,
36foreign key ("rule_name") references "auth_rule"("name") on delete set null,
37primary key ("name")
38);
39-- adds oracle specific index to auth_item
40CREATE INDEX auth_type_index ON "auth_item"("type");
41
42create table "auth_item_child"
43(
44"parent" varchar(64) not null,
45"child" varchar(64) not null,
46primary key ("parent","child"),
47foreign key ("parent") references "auth_item"("name") on delete cascade,
48foreign key ("child") references "auth_item"("name") on delete cascade
49);
50
51create table "auth_assignment"
52(
53"item_name" varchar(64) not null,
54"user_id" varchar(64) not null,
55"created_at" integer,
56primary key ("item_name","user_id"),
57foreign key ("item_name") references "auth_item" ("name") on delete cascade
58);
59
60CREATE INDEX auth_assignment_user_id_idx ON "auth_assignment" ("user_id");
61