Passed
Branch master (c62005)
by ABDULMALIK
02:15
created

CreateRole::change()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

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