schema-pgsql.sql 1.41 KB
Newer Older
Alexander Kochetov committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/**
 * Database schema required by \yii\rbac\DbManager.
 *
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @author Alexander Kochetov <creocoder@gmail.com>
 * @link http://www.yiiframework.com/
 * @copyright 2008 Yii Software LLC
 * @license http://www.yiiframework.com/license/
 * @since 2.0
 */

drop table if exists "tbl_auth_assignment";
drop table if exists "tbl_auth_item_child";
drop table if exists "tbl_auth_item";

create table "tbl_auth_item"
(
   "name"                 varchar(64) not null,
   "type"                 integer not null,
   "description"          text,
Qiang Xue committed
21
   "biz_rule"              text,
Alexander Kochetov committed
22
   "data"                 text,
23
   primary key ("name")
Alexander Kochetov committed
24 25
);

26 27
create index tbl_auth_item_type_idx on "tbl_auth_item" ("type");

Alexander Kochetov committed
28 29 30 31 32 33 34 35 36 37 38
create table "tbl_auth_item_child"
(
   "parent"               varchar(64) not null,
   "child"                varchar(64) not null,
   primary key ("parent","child"),
   foreign key ("parent") references "tbl_auth_item" ("name") on delete cascade on update cascade,
   foreign key ("child") references "tbl_auth_item" ("name") on delete cascade on update cascade
);

create table "tbl_auth_assignment"
(
39 40
   "item_name"            varchar(64) not null,
   "user_id"              varchar(64) not null,
Qiang Xue committed
41
   "biz_rule"              text,
Alexander Kochetov committed
42 43 44 45
   "data"                 text,
   primary key ("item_name","user_id"),
   foreign key ("item_name") references "tbl_auth_item" ("name") on delete cascade on update cascade
);