|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace OcMigrations; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\DBAL\Schema\Schema; |
|
8
|
|
|
use Doctrine\Migrations\AbstractMigration; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Auto-generated Migration: Please modify to your needs! |
|
12
|
|
|
*/ |
|
13
|
|
|
final class Version20201014195236 extends AbstractMigration |
|
|
|
|
|
|
14
|
|
|
{ |
|
15
|
|
|
public function getDescription() : string |
|
16
|
|
|
{ |
|
17
|
|
|
return 'Create security tables'; |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
public function up(Schema $schema) : void |
|
21
|
|
|
{ |
|
22
|
|
|
$this->addSql(' |
|
23
|
|
|
create table security_roles |
|
24
|
|
|
( |
|
25
|
|
|
id int auto_increment, |
|
26
|
|
|
role varchar(100) not null, |
|
27
|
|
|
constraint security_roles_pk |
|
28
|
|
|
primary key (id) |
|
29
|
|
|
); |
|
30
|
|
|
|
|
31
|
|
|
create unique index security_roles_role_uindex |
|
32
|
|
|
on security_roles (role); |
|
33
|
|
|
'); |
|
34
|
|
|
|
|
35
|
|
|
$this->addSql(' |
|
36
|
|
|
create table security_role_hierarchy |
|
37
|
|
|
( |
|
38
|
|
|
role_id int not null, |
|
39
|
|
|
sub_role_id int not null, |
|
40
|
|
|
constraint security_role_hierarchy_pk |
|
41
|
|
|
primary key (role_id, sub_role_id), |
|
42
|
|
|
constraint security_role_hierarchy_pk_2 |
|
43
|
|
|
unique (role_id, sub_role_id), |
|
44
|
|
|
constraint security_role_hierarchy_security_roles_id_fk |
|
45
|
|
|
foreign key (role_id) references security_roles (id), |
|
46
|
|
|
constraint security_role_hierarchy_security_roles_id_fk_2 |
|
47
|
|
|
foreign key (sub_role_id) references security_roles (id) |
|
48
|
|
|
); |
|
49
|
|
|
'); |
|
50
|
|
|
|
|
51
|
|
|
$this->addSql(' |
|
52
|
|
|
INSERT INTO security_roles (role) |
|
53
|
|
|
VALUES (\'ROLE_USER\'), |
|
54
|
|
|
(\'ROLE_TEAM\'), |
|
55
|
|
|
(\'ROLE_SUPPORT_CLEAN\'), |
|
56
|
|
|
(\'ROLE_SUPPORT_MAINTAIN\'), |
|
57
|
|
|
(\'ROLE_SUPPORT_HEAD\'), |
|
58
|
|
|
(\'ROLE_SOCIAL\'), |
|
59
|
|
|
(\'ROLE_SOCIAL_HEAD\'), |
|
60
|
|
|
(\'ROLE_DEVELOPER_CORE\'), |
|
61
|
|
|
(\'ROLE_DEVELOPER_CONTRIBUTE\'), |
|
62
|
|
|
(\'ROLE_DEVELOPER_HEAD\'), |
|
63
|
|
|
(\'ROLE_ADMIN\'), |
|
64
|
|
|
(\'ROLE_SUPER_ADMIN\'); |
|
65
|
|
|
'); |
|
66
|
|
|
|
|
67
|
|
|
$this->addSql(' |
|
68
|
|
|
INSERT INTO security_role_hierarchy (role_id, sub_role_id) |
|
69
|
|
|
VALUES (2, 1), |
|
70
|
|
|
(3, 2), |
|
71
|
|
|
(4, 2), |
|
72
|
|
|
(6, 2), |
|
73
|
|
|
(8, 2), |
|
74
|
|
|
(5, 3), |
|
75
|
|
|
(5, 4), |
|
76
|
|
|
(10, 8), |
|
77
|
|
|
(10, 9), |
|
78
|
|
|
(11, 5), |
|
79
|
|
|
(11, 7), |
|
80
|
|
|
(11, 10), |
|
81
|
|
|
(12, 11); |
|
82
|
|
|
'); |
|
83
|
|
|
|
|
84
|
|
|
$this->addSql(' |
|
85
|
|
|
create table user_roles |
|
86
|
|
|
( |
|
87
|
|
|
id int auto_increment, |
|
88
|
|
|
user_id int(10) unsigned not null, |
|
89
|
|
|
role_id int(11) not null, |
|
90
|
|
|
constraint user_roles_pk |
|
91
|
|
|
primary key (id), |
|
92
|
|
|
constraint user_roles_security_roles_id_fk |
|
93
|
|
|
foreign key (role_id) references security_roles (id), |
|
94
|
|
|
constraint user_roles_user_user_id_fk |
|
95
|
|
|
foreign key (user_id) references user (user_id) |
|
96
|
|
|
); |
|
97
|
|
|
|
|
98
|
|
|
create unique index user_roles_user_id_role_id_uindex |
|
99
|
|
|
on user_roles (user_id, role_id); |
|
100
|
|
|
'); |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|