Completed
Push — master ( 9ba851...d8a65a )
by Vladimir
09:32 queued 26s
created

BanMuteSupportIssue157::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
dl 14
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
use Phinx\Migration\AbstractMigration;
4
5
/**
6
 * Restructure the `bans` table to better support bans and mutes.
7
 *
8
 * - The `allow_server_join` column was never correctly used and therefore has been dropped; due to incorrect use, the
9
 *   data did not need to be migrated or saved.
10
 * - The `is_soft_ban` column is being added to differentiate between bans that should penalize players on the site
11
 *   itself and bans that will only affect players on league servers. A soft ban will not affect a player on BZiON.
12
 *
13
 * @link https://github.com/allejo/bzion/issues/157
14
 */
15
class BanMuteSupportIssue157 extends AbstractMigration
16
{
17 View Code Duplication
    public function up()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
    {
19
        $bansTable = $this->table('bans');
20
        $bansTable
21
            ->removeColumn('allow_server_join')
22
            ->addColumn('is_soft_ban', 'boolean', [
23
                'after' => 'author',
24
                'null' => false,
25
                'default' => false,
26
                'comment' => 'A soft ban will not penalize a user on the site or servers',
27
            ])
28
            ->update()
29
        ;
30
31
        // Unban any currently banned players
32
        $this->query("UPDATE players SET status = 'active' WHERE status = 'banned';");
33
    }
34
35 View Code Duplication
    public function down()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
    {
37
        $bansTable = $this->table('bans');
38
        $bansTable
39
            ->removeColumn('is_soft_ban')
40
            ->addColumn('allow_server_join', 'boolean', [
41
                'after' => 'reason',
42
                'null' => false,
43
                'default' => false,
44
                'comment' => 'Whether or not to allow players to join servers while banned'
45
            ])
46
            ->update()
47
        ;
48
    }
49
}
50