Passed
Push — master ( 1d5530...fba2a1 )
by Nico
56:37 queued 25:57
created

Version20240711113958_WormholeEntry::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 7
ccs 0
cts 5
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Migrations;
6
7
use Doctrine\DBAL\Schema\Schema;
8
use Doctrine\Migrations\AbstractMigration;
9
10
final class Version20240711113958_WormholeEntry extends AbstractMigration
11
{
12
    public function getDescription(): string
13
    {
14
        return 'Convert wormhole entry type to enum string.';
15
    }
16
17
    public function up(Schema $schema): void
18
    {
19
        $this->addSql('ALTER TABLE stu_wormhole_entry ALTER type TYPE VARCHAR(10)');
20
21
        $this->addSql('UPDATE stu_wormhole_entry SET type = \'MAP -> W\' WHERE type = \'0\'');
22
        $this->addSql('UPDATE stu_wormhole_entry SET type = \'W -> MAP\' WHERE type = \'1\'');
23
        $this->addSql('UPDATE stu_wormhole_entry SET type = \'MAP <-> W\' WHERE type = \'2\'');
24
    }
25
26
    public function down(Schema $schema): void
27
    {
28
        $this->addSql('UPDATE stu_wormhole_entry SET type = \'0\' WHERE type = \'MAP -> W\'');
29
        $this->addSql('UPDATE stu_wormhole_entry SET type = \'1\' WHERE type = \'W -> MAP\'');
30
        $this->addSql('UPDATE stu_wormhole_entry SET type = \'2\' WHERE type = \'MAP <-> W\'');
31
32
        $this->addSql('ALTER TABLE stu_wormhole_entry ALTER type TYPE SMALLINT USING type::smallint');
33
    }
34
}
35