Completed
Push — hotfix/dbm-wo-models ( fe953c )
by Vladimir
03:37
created

ClearDeletedTeamAvatars   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 46
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B up() 0 40 1
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