Code Duplication    Length = 41-42 lines in 2 locations

migrations/20180209070716_make_invitations_better.php 1 location

@@ 7-47 (lines=41) @@
4
5
class MakeInvitationsBetter extends AbstractMigration
6
{
7
    public function change()
8
    {
9
        $invitationsTable = $this->table('invitations');
10
        $invitationsTable
11
            ->addColumn('sent', 'datetime', [
12
                'after' => 'team',
13
                'null' => true,
14
                'default' => null,
15
                'comment' => 'When the invitation was sent',
16
            ])
17
            ->addColumn('status', 'integer', [
18
                'after' => 'text',
19
                'null' => false,
20
                'default' => 0,
21
                'signed' => true,
22
                'length' => 1,
23
                'comment' => '0: pending; 1: accepted; 2: rejected',
24
            ])
25
            ->addColumn('is_deleted', 'boolean', [
26
                'after' => 'status',
27
                'null' => false,
28
                'default' => false,
29
                'comment' => 'Whether or not the invitation has been soft deleted',
30
            ])
31
            ->update()
32
        ;
33
34
        $invitationsTable
35
            ->renameColumn('text', 'message')
36
            ->update()
37
        ;
38
39
        $invitationsTable
40
            ->changeColumn('message', 'text', [
41
                'null' => true,
42
                'default' => null,
43
                'comment' => 'The message sent when inviting a player to a team',
44
            ])
45
            ->update()
46
        ;
47
    }
48
}
49

migrations/20180211020823_server_status_column_conversation.php 1 location

@@ 7-48 (lines=42) @@
4
5
class ServerStatusColumnConversation extends AbstractMigration
6
{
7
    public function up()
8
    {
9
        $serversTable = $this->table('servers');
10
        $serversTable
11
            ->addColumn('is_official_server', 'boolean', [
12
                'after' => 'updated',
13
                'null' => false,
14
                'default' => false,
15
                'comment' => 'Whether or not this server is capable of hosting official matches',
16
            ])
17
            ->addColumn('is_replay_server', 'boolean', [
18
                'after' => 'is_official_server',
19
                'null' => false,
20
                'default' => false,
21
                'comment' => 'Whether or not this server is dedicated to serving replays of matches',
22
            ])
23
            ->addColumn('is_inactive', 'boolean', [
24
                'after' => 'is_replay_server',
25
                'null' => false,
26
                'default' => false,
27
                'comment' => 'Whether or not this server is no longer active but still required for historical purposes',
28
29
            ])
30
            ->addColumn('is_deleted', 'boolean', [
31
                'after' => 'is_inactive',
32
                'null' => false,
33
                'default' => false,
34
                'comment' => 'Whether or not this server has been soft deleted',
35
            ])
36
            ->update()
37
        ;
38
39
        // BZiON 0.10.x and below required that you soft deleted servers so they'd no longer appear on the server list.
40
        // For this reason and because Leagues United is the only known installation, we'll be assuming that deleted
41
        // servers were just meant to be marked as "inactive."
42
        $this->query("UPDATE servers SET is_inactive = 1 WHERE status = 'deleted';");
43
44
        $serversTable
45
            ->removeColumn('status')
46
            ->update()
47
        ;
48
    }
49
50
    public function down()
51
    {