Completed
Push — master ( 3323b4...560235 )
by Anton
12s
created

AclData::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
use Phinx\Migration\AbstractMigration;
4
5
class AclData extends AbstractMigration
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
6
{
7
    /**
8
     * Migrate Up.
9
     */
10
    public function up()
11
    {
12
        $roles = [
13
            [
14
                'id' => 1,
15
                'name' => 'system'
16
            ],
17
            [
18
                'id' => 2,
19
                'name' => 'admin'
20
            ],
21
            [
22
                'id' => 3,
23
                'name' => 'member'
24
            ],
25
            [
26
                'id' => 4,
27
                'name' => 'guest'
28
            ],
29
        ];
30
        $this->table('acl_roles')->insert($roles)->save();
31
32
        $privileges = [
33
            [
34
                'roleId' => 2,
35
                'module' => 'acl',
36
                'privilege' => 'Management'
37
            ],
38
            [
39
                'roleId' => 2,
40
                'module' => 'acl',
41
                'privilege' => 'View'
42
            ],
43
            [
44
                'roleId' => 2,
45
                'module' => 'api',
46
                'privilege' => 'Users/Id'
47
            ],
48
            [
49
                'roleId' => 2,
50
                'module' => 'api',
51
                'privilege' => 'Users/Profile'
52
            ],
53
            [
54
                'roleId' => 2,
55
                'module' => 'cache',
56
                'privilege' => 'Management'
57
            ],
58
            [
59
                'roleId' => 2,
60
                'module' => 'dashboard',
61
                'privilege' => 'Dashboard'
62
            ],
63
            [
64
                'roleId' => 2,
65
                'module' => 'pages',
66
                'privilege' => 'Management'
67
            ],
68
            [
69
                'roleId' => 2,
70
                'module' => 'system',
71
                'privilege' => 'Info'
72
            ],
73
            [
74
                'roleId' => 2,
75
                'module' => 'users',
76
                'privilege' => 'EditEmail'
77
            ],
78
            [
79
                'roleId' => 2,
80
                'module' => 'users',
81
                'privilege' => 'EditPassword'
82
            ],
83
            [
84
                'roleId' => 2,
85
                'module' => 'users',
86
                'privilege' => 'Management'
87
            ],
88
            [
89
                'roleId' => 2,
90
                'module' => 'users',
91
                'privilege' => 'ViewProfile'
92
            ],
93
            [
94
                'roleId' => 3,
95
                'module' => 'api',
96
                'privilege' => 'Users/Profile'
97
            ],
98
            [
99
                'roleId' => 3,
100
                'module' => 'users',
101
                'privilege' => 'EditEmail'
102
            ],
103
            [
104
                'roleId' => 3,
105
                'module' => 'users',
106
                'privilege' => 'EditPassword'
107
            ],
108
            [
109
                'roleId' => 3,
110
                'module' => 'users',
111
                'privilege' => 'ViewProfile'
112
            ],
113
        ];
114
        $this->table('acl_privileges')->insert($privileges)->save();
115
116
        $usersRoles = [
117
            [
118
                'userId' => 1,
119
                'roleId' => 1
120
            ],
121
            [
122
                'userId' => 2,
123
                'roleId' => 2
124
            ],
125
            [
126
                'userId' => 3,
127
                'roleId' => 3
128
            ],
129
        ];
130
        $this->table('acl_users_roles')->insert($usersRoles)->save();
131
    }
132
133
    /**
134
     * Migrate Down.
135
     */
136
    public function down()
137
    {
138
        $this->execute('DELETE FROM acl_users_roles');
139
        $this->execute('DELETE FROM acl_privileges');
140
        $this->execute('DELETE FROM acl_roles');
141
    }
142
}
143