Krzysztof Andrzej Sikorski commited on 2022-04-25 21:43:00
Showing 2 changed files, with 73 additions and 0 deletions.
... | ... |
@@ -0,0 +1,70 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+declare(strict_types=1); |
|
4 |
+ |
|
5 |
+namespace DoctrineMigrations; |
|
6 |
+ |
|
7 |
+use App\Contract\Entity\Nexus\GamePeriodIdEnum; |
|
8 |
+use Doctrine\DBAL\Schema\Schema; |
|
9 |
+use Doctrine\DBAL\Types\Types; |
|
10 |
+use Doctrine\Migrations\AbstractMigration; |
|
11 |
+ |
|
12 |
+use function array_merge; |
|
13 |
+ |
|
14 |
+final class Version0010 extends AbstractMigration |
|
15 |
+{ |
|
16 |
+ private const TS_BREATH_5_LAUNCH = '2021-11-24 00:00:00 UTC'; |
|
17 |
+ private const TS_BREATH_5_OUTER_PLANES = '2021-12-26 00:00:00 UTC'; |
|
18 |
+ private const TS_BREATH_5_STRONGHOLDS = '2022-03-06 00:00:00 UTC'; |
|
19 |
+ |
|
20 |
+ public function getDescription(): string |
|
21 |
+ { |
|
22 |
+ return 'Insert rows for known game periods (up to B5 Stronghold launch)'; |
|
23 |
+ } |
|
24 |
+ |
|
25 |
+ public function up(Schema $schema): void |
|
26 |
+ { |
|
27 |
+ $sql = <<<'SQL' |
|
28 |
+ INSERT INTO nexus_game_period (id, name, started_at, completed_at, current) |
|
29 |
+ VALUES (:id, :name, :startedAt, :completedAt, :current) |
|
30 |
+ SQL; |
|
31 |
+ $rows = [ |
|
32 |
+ GamePeriodIdEnum::BREATH_5_LAUNCH => [ |
|
33 |
+ 'name' => 'Breath 5 (early after launch)', |
|
34 |
+ 'startedAt' => self::TS_BREATH_5_LAUNCH, |
|
35 |
+ 'completedAt' => self::TS_BREATH_5_OUTER_PLANES, |
|
36 |
+ 'current' => false, |
|
37 |
+ ], |
|
38 |
+ GamePeriodIdEnum::BREATH_5_OUTER_PLANES => [ |
|
39 |
+ 'name' => 'Breath 5 (after opening of Outer Planes)', |
|
40 |
+ 'startedAt' => self::TS_BREATH_5_OUTER_PLANES, |
|
41 |
+ 'completedAt' => self::TS_BREATH_5_STRONGHOLDS, |
|
42 |
+ 'current' => false, |
|
43 |
+ ], |
|
44 |
+ GamePeriodIdEnum::BREATH_5_STRONGHOLDS => [ |
|
45 |
+ 'name' => 'Breath 5 (after launch of Strongholds)', |
|
46 |
+ 'startedAt' => self::TS_BREATH_5_STRONGHOLDS, |
|
47 |
+ 'completedAt' => null, |
|
48 |
+ 'current' => true, |
|
49 |
+ ], |
|
50 |
+ ]; |
|
51 |
+ $types = [ |
|
52 |
+ 'name' => Types::TEXT, |
|
53 |
+ 'startedAt' => Types::TEXT, |
|
54 |
+ 'completedAt' => Types::TEXT, |
|
55 |
+ 'current' => Types::BOOLEAN, |
|
56 |
+ ]; |
|
57 |
+ foreach ($rows as $id => $row) { |
|
58 |
+ $params = array_merge(['id' => $id], $row); |
|
59 |
+ $this->addSql(sql: $sql, params: $params, types: $types); |
|
60 |
+ } |
|
61 |
+ } |
|
62 |
+ |
|
63 |
+ public function down(Schema $schema): void |
|
64 |
+ { |
|
65 |
+ $this->addSql( |
|
66 |
+ sql: 'DELETE FROM nexus_game_period WHERE id != :idBreath4', |
|
67 |
+ params: ['idBreath4' => GamePeriodIdEnum::BREATH_4] |
|
68 |
+ ); |
|
69 |
+ } |
|
70 |
+} |