Completed
Pull Request — master (#186)
by Vladimir
16:33 queued 13:26
created

MakeInvitationsBetter::change()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 41
Code Lines 30

Duplication

Lines 41
Ratio 100 %

Importance

Changes 0
Metric Value
dl 41
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 View Code Duplication
    public function change()
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...
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