Completed
Push — master ( ec1e51...6dfbc7 )
by Anton
02:33
created

ModuleTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 62
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B change() 0 37 1
1
<?php
2
/**
3
 * @copyright Bluz PHP Team
4
 * @link https://github.com/bluzphp/skeleton
5
 */
6
7
use Phinx\Migration\AbstractMigration;
8
9
/**
10
 * CreateTestTable
11
 */
12
class ModuleTest 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...
13
{
14
15
    /**
16
     * Change Method.
17
     *
18
     * Write your reversible migrations using this method.
19
     *
20
     * More information on writing migrations is available here:
21
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
22
     *
23
     * The following commands can be used in this method and Phinx will
24
     * automatically reverse them when rolling back:
25
     *
26
     *    createTable
27
     *    renameTable
28
     *    addColumn
29
     *    renameColumn
30
     *    addIndex
31
     *    addForeignKey
32
     *
33
     * Remember to call "create()" or "update()" and NOT "save()" when working
34
     * with the Table class.
35
     */
36
    public function change()
37
    {
38
        $table = $this->table('test');
39
        $table
40
            ->addColumn('name', 'string', ['length' => 255])
41
            ->addColumn('email', 'string', ['length' => 255, 'null' => true])
42
            ->addColumn('status', 'enum', ['values' => ['active', 'disable', 'delete']])
43
            ->addTimestamps('created', 'updated')
44
            ->create();
45
46
        $data = [
47
            [
48
                'roleId' => 2,
49
                'module' => 'test',
50
                'privilege' => 'Create'
51
            ],
52
            [
53
                'roleId' => 2,
54
                'module' => 'test',
55
                'privilege' => 'Read'
56
            ],
57
            [
58
                'roleId' => 2,
59
                'module' => 'test',
60
                'privilege' => 'Update'
61
            ],
62
            [
63
                'roleId' => 2,
64
                'module' => 'test',
65
                'privilege' => 'Delete'
66
            ],
67
        ];
68
69
        $privileges = $this->table('acl_privileges');
70
        $privileges->insert($data)
71
            ->save();
72
    }
73
}
74