Completed
Push — master ( a398f5...dae853 )
by Anton
02:37
created

Options::change()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 9.0856
c 0
b 0
f 0
cc 1
eloc 16
nc 1
nop 0
1
<?php
2
3
use Phinx\Migration\AbstractMigration;
4
5
class Options 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
     * Change Method.
9
     *
10
     * Write your reversible migrations using this method.
11
     *
12
     * More information on writing migrations is available here:
13
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
14
     *
15
     * The following commands can be used in this method and Phinx will
16
     * automatically reverse them when rolling back:
17
     *
18
     *    createTable
19
     *    renameTable
20
     *    addColumn
21
     *    renameColumn
22
     *    addIndex
23
     *    addForeignKey
24
     *
25
     * Remember to call "create()" or "update()" and NOT "save()" when working
26
     * with the Table class.
27
     */
28
    public function change()
29
    {
30
        $pages = $this->table('options', ['id' => false, 'primary_key' => ['namespace', 'key']]);
31
        $pages
32
            ->addColumn('namespace', 'string', ['length' => 255, 'default' => 'default'])
33
            ->addColumn('key', 'string', ['length' => 255])
34
            ->addColumn('value', 'text')
35
            ->addColumn('description', 'text', ['null' => true])
36
            ->addTimestamps('created', 'updated')
37
            ->create();
38
39
        $data = [
40
            [
41
                'roleId' => 2,
42
                'module' => 'options',
43
                'privilege' => 'Management'
44
            ]
45
        ];
46
47
        $privileges = $this->table('acl_privileges');
48
        $privileges->insert($data)
49
            ->save();
50
    }
51
}
52