Completed
Push — master ( d3b38e...70fe6c )
by Vladimir
05:42
created

ClearDeletedTeamAvatars::up()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 40
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 17
nc 1
nop 0
1
<?php
2
3
use BZIon\Phinx\KernelReadyMigration;
4
5
class ClearDeletedTeamAvatars extends KernelReadyMigration
6
{
7
    /**
8
     * {@inheritdoc}
9
     */
10
    public function up()
11
    {
12
        $playersTable = $this->table('players');
13
        $playersTable
14
            ->changeColumn('avatar', 'string', [
15
                'limit' => 200,
16
                'null' => true,
17
                'comment' => "The path to the player's avatar relative to the bzion project root",
18
            ])
19
            ->update()
20
        ;
21
22
        $this->execute("
23
            UPDATE
24
                players
25
            SET
26
                avatar = NULL 
27
            WHERE
28
                status IN ('deleted', 'disabled')
29
        ");
30
31
        $teamsTable = $this->table('teams');
32
        $teamsTable
33
            ->changeColumn('avatar', 'string', [
34
                'limit' => 200,
35
                'null' => true,
36
                'comment' => "The path to the player's avatar relative to the bzion project root",
37
            ])
38
            ->update()
39
        ;
40
41
        $this->execute("
42
            UPDATE
43
                teams
44
            SET
45
                avatar = NULL
46
            WHERE
47
                status IN ('deleted', 'disabled')
48
        ");
49
    }
50
}
51