Passed
Push — dev ( 05cdef...61c72f )
by Janko
09:21
created

Version20241215133617_Direction_Nullable::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
rs 10
c 1
b 1
f 0
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