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

Version20240711113958_WormholeEntry   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 23
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 7 1
A down() 0 7 1
A getDescription() 0 3 1
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