Passed
Push — master ( d0c183...89bdb5 )
by Janko
13:17
created

Version20240705092745_StarSystem   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Migrations\Pgsql;
6
7
use Override;
8
use Doctrine\DBAL\Schema\Schema;
9
use Doctrine\Migrations\AbstractMigration;
10
11
final class Version20240705092745_StarSystem extends AbstractMigration
12
{
13
    #[Override]
14
    public function getDescription(): string
15
    {
16
        return 'Removes the following obsolete fields from stu_systems: cx, cy';
17
    }
18
19
    #[Override]
20
    public function up(Schema $schema): void
21
    {
22
        $this->addSql('DROP INDEX coordinate_idx;');
23
        $this->addSql('ALTER TABLE stu_systems DROP cx;');
24
        $this->addSql('ALTER TABLE stu_systems DROP cy;');
25
    }
26
27
    #[Override]
28
    public function down(Schema $schema): void
29
    {
30
        $this->addSql('ALTER TABLE stu_systems ADD cx SMALLINT DEFAULT NULL;');
31
        $this->addSql('ALTER TABLE stu_systems ADD cy SMALLINT DEFAULT NULL;');
32
        $this->addSql('CREATE INDEX coordinate_idx ON stu_systems (cx, cy);');
33
    }
34
}
35