Passed
Pull Request — master (#50)
by Ronan
10:11
created

UserManagement   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 16
dl 0
loc 33
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A change() 0 20 1
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