Passed
Pull Request — master (#50)
by Ronan
09:06
created

UserManagement::change()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 20
rs 9.7666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
use App\Model\User;
5
use Phinx\Migration\AbstractMigration;
6
7
final class UserManagement extends AbstractMigration
8
{
9
    /**
10
     * Change Method.
11
     *
12
     * Write your reversible migrations using this method.
13
     *
14
     * More information on writing migrations is available here:
15
     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
16
     *
17
     * Remember to call "create()" or "update()" and NOT "save()" when working
18
     * with the Table class.
19
     */
20
    public function change(): void
21
    {
22
        $users = $this->table(User::table());
23
        $users
24
            ->addColumn('user_level', 'string', [
25
                'length' => 16,
26
                'null'   => false,
27
                'after'  => 'user_preferences',
28
            ])
29
            ->addColumn('user_hash', 'string', [
30
                'length' => 32,
31
                'null'   => false,
32
                'after'  => 'user_level',
33
            ])
34
            ->addColumn('user_last_login', 'datetime', [
35
                'null' => true,
36
                'default' => null,
37
                'after'  => 'user_hash',
38
            ])
39
            ->update();
40
    }
41
}
42