Completed
Push — feature/pixie-port ( b3acf3...e69309 )
by Vladimir
03:27
created

MakeInvitationsBetter::change()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 41
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 41
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 30
nc 1
nop 0
1
<?php
2
3
use Phinx\Migration\AbstractMigration;
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