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

Version20241215133617_Direction_Nullable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 10
dl 0
loc 21
rs 10
c 1
b 1
f 0
wmc 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Migrations\Pgsql;
6
7
use Doctrine\DBAL\Schema\Schema;
8
use Doctrine\Migrations\AbstractMigration;
9
10
final class Version20241215133617_Direction_Nullable extends AbstractMigration
11
{
12
    public function getDescription(): string
13
    {
14
        return '';
15
    }
16
17
    public function up(Schema $schema): void
18
    {
19
        $this->addSql('ALTER TABLE stu_flight_sig ALTER from_direction DROP NOT NULL');
20
        $this->addSql('ALTER TABLE stu_flight_sig ALTER to_direction DROP NOT NULL');
21
        $this->addSql('UPDATE stu_flight_sig SET from_direction = null WHERE from_direction = 0');
22
        $this->addSql('UPDATE stu_flight_sig SET to_direction = null WHERE to_direction = 0');
23
    }
24
25
    public function down(Schema $schema): void
26
    {
27
        $this->addSql('UPDATE stu_flight_sig SET from_direction = 0 WHERE from_direction IS null');
28
        $this->addSql('UPDATE stu_flight_sig SET to_direction = 0 WHERE to_direction IS null');
29
        $this->addSql('ALTER TABLE stu_flight_sig ALTER from_direction SET NOT NULL');
30
        $this->addSql('ALTER TABLE stu_flight_sig ALTER to_direction SET NOT NULL');
31
    }
32
}
33