yii2
57 строк · 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 if exists `auth_assignment`;
13drop table if exists `auth_item_child`;
14drop table if exists `auth_item`;
15drop table if exists `auth_rule`;
16
17create table `auth_rule`
18(
19`name` varchar(64) not null,
20`data` blob,
21`created_at` integer,
22`updated_at` integer,
23primary key (`name`)
24) engine InnoDB;
25
26create table `auth_item`
27(
28`name` varchar(64) not null,
29`type` smallint not null,
30`description` text,
31`rule_name` varchar(64),
32`data` blob,
33`created_at` integer,
34`updated_at` integer,
35primary key (`name`),
36foreign key (`rule_name`) references `auth_rule` (`name`) on delete set null on update cascade,
37key `type` (`type`)
38) engine InnoDB;
39
40create table `auth_item_child`
41(
42`parent` varchar(64) not null,
43`child` varchar(64) not null,
44primary key (`parent`, `child`),
45foreign key (`parent`) references `auth_item` (`name`) on delete cascade on update cascade,
46foreign key (`child`) references `auth_item` (`name`) on delete cascade on update cascade
47) engine InnoDB;
48
49create table `auth_assignment`
50(
51`item_name` varchar(64) not null,
52`user_id` varchar(64) not null,
53`created_at` integer,
54primary key (`item_name`, `user_id`),
55foreign key (`item_name`) references `auth_item` (`name`) on delete cascade on update cascade,
56key `auth_assignment_user_id_idx` (`user_id`)
57) engine InnoDB;
58