CreatePermission::change()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 10
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
use Phinx\Migration\AbstractMigration;
4
5
/**
6
 * Class CreatePermission
7
 */
8
class CreatePermission extends AbstractMigration
9
{
10
    /**
11
     * Create permission table in database.
12
     * Field 'name' is unique index.
13
     */
14
    public function change()
15
    {
16
        $permissionTable = $this->table('permission', ['signed' => false]);
17
18
        $permissionTable->addColumn('name', 'string', ['limit' => 100])
19
            ->addColumn('status', 'boolean', ['default' => true])
20
            ->addColumn('created_at', 'datetime')
21
            ->addColumn('updated_at', 'datetime', ['null' => true])
22
            ->addIndex('name', ['name' => 'idx_permission_name' ,'unique' => true])
23
            ->create();
24
    }
25
}
26