|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use Phinx\Migration\AbstractMigration; |
|
4
|
|
|
|
|
5
|
|
|
class PlayerElo extends AbstractMigration |
|
6
|
|
|
{ |
|
7
|
|
|
/** |
|
8
|
|
|
* {@inheritdoc} |
|
9
|
|
|
*/ |
|
10
|
|
|
public function change() |
|
11
|
|
|
{ |
|
12
|
|
|
$matches = $this->table('matches'); |
|
13
|
|
|
$matches |
|
14
|
|
|
->addColumn('player_elo_diff', 'integer', [ |
|
15
|
|
|
'after' => 'elo_diff', |
|
16
|
|
|
'limit' => 5, |
|
17
|
|
|
'signed' => true, |
|
18
|
|
|
'null' => true, |
|
19
|
|
|
'comment' => 'The change in ELO for players', |
|
20
|
|
|
]) |
|
21
|
|
|
->update() |
|
22
|
|
|
; |
|
23
|
|
|
|
|
24
|
|
|
$playerELOs = $this->table('player_elo', [ |
|
25
|
|
|
'id' => false, |
|
26
|
|
|
'primary_key' => ['user_id', 'match_id'] |
|
27
|
|
|
]); |
|
28
|
|
|
$playerELOs |
|
29
|
|
|
->addColumn('user_id', 'integer', [ |
|
30
|
|
|
'limit' => 10, |
|
31
|
|
|
'signed' => false, |
|
32
|
|
|
'null' => false, |
|
33
|
|
|
'comment' => 'The player whose had their individual ELO change', |
|
34
|
|
|
]) |
|
35
|
|
|
->addColumn('match_id', 'integer', [ |
|
36
|
|
|
'limit' => 10, |
|
37
|
|
|
'signed' => false, |
|
38
|
|
|
'null' => false, |
|
39
|
|
|
'comment' => 'The match the player participated in, which resulted in this ELO change', |
|
40
|
|
|
]) |
|
41
|
|
|
->addColumn('season_period', 'set', [ |
|
42
|
|
|
'values' => ['winter', 'spring', 'summer', 'fall'], |
|
43
|
|
|
'null' => false, |
|
44
|
|
|
'comment' => 'The season this ELO change occurred in', |
|
45
|
|
|
]) |
|
46
|
|
|
->addColumn('season_year', 'integer', [ |
|
47
|
|
|
'limit' => 4, |
|
48
|
|
|
'signed' => false, |
|
49
|
|
|
'null' => false, |
|
50
|
|
|
'comment' => 'The year of the season' |
|
51
|
|
|
]) |
|
52
|
|
|
->addColumn('elo_previous', 'integer', [ |
|
53
|
|
|
'signed' => false, |
|
54
|
|
|
'null' => false, |
|
55
|
|
|
'comment' => 'The ELO the player had prior to participating in this match', |
|
56
|
|
|
]) |
|
57
|
|
|
->addColumn('elo_new', 'integer', [ |
|
58
|
|
|
'signed' => false, |
|
59
|
|
|
'null' => false, |
|
60
|
|
|
'comment' => 'The new ELO for the player after participating in this match', |
|
61
|
|
|
]) |
|
62
|
|
|
->addForeignKey('user_id', 'players', 'id', ['delete' => 'CASCADE']) |
|
63
|
|
|
->addForeignKey('match_id', 'matches', 'id', ['delete' => 'CASCADE']) |
|
64
|
|
|
->create() |
|
65
|
|
|
; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|