schema-mysql.sql 1.74 KB
Newer Older
Alexander Kochetov committed
1 2 3 4 5 6 7 8 9 10 11
/**
 * 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
 */

12 13 14
drop table if exists `auth_assignment`;
drop table if exists `auth_item_child`;
drop table if exists `auth_item`;
15 16 17 18 19 20 21 22
drop table if exists `auth_rule`;

create table `auth_rule`
(
    `name`  varchar(64) not null,
    `data`  text,
    primary key (`name`)
) engine InnoDB;
Alexander Kochetov committed
23

24
create table `auth_item`
Alexander Kochetov committed
25 26 27 28
(
   `name`                 varchar(64) not null,
   `type`                 integer not null,
   `description`          text,
29
   `rule_name`            varchar(64),
Alexander Kochetov committed
30
   `data`                 text,
Qiang Xue committed
31
   primary key (`name`),
32
   foreign key (`rule_name`) references `auth_rule` (`name`) on delete set null on update cascade,
Qiang Xue committed
33
   key `type` (`type`)
Alexander Kochetov committed
34 35
) engine InnoDB;

36
create table `auth_item_child`
Alexander Kochetov committed
37 38 39
(
   `parent`               varchar(64) not null,
   `child`                varchar(64) not null,
40
   primary key (`parent`, `child`),
41 42
   foreign key (`parent`) references `auth_item` (`name`) on delete cascade on update cascade,
   foreign key (`child`) references `auth_item` (`name`) on delete cascade on update cascade
Alexander Kochetov committed
43 44
) engine InnoDB;

45
create table `auth_assignment`
Alexander Kochetov committed
46
(
47 48
   `item_name`            varchar(64) not null,
   `user_id`              varchar(64) not null,
49
   `rule_name`            varchar(64),
Alexander Kochetov committed
50
   `data`                 text,
51 52 53 54
   primary key (`item_name`, `user_id`),
   foreign key (`item_name`) references `auth_item` (`name`) on delete cascade on update cascade,
   foreign key (`rule_name`) references `auth_rule` (`name`) on delete set null on update cascade
) engine InnoDB;