Passed
Pull Request — master (#2161)
by Janko
25:16 queued 15:11
created

Version20250619092054::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 12
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 12
rs 9.8666
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 Version20250619092054 extends AbstractMigration
11
{
12
    public function getDescription(): string
13
    {
14
        return 'Optimized foreign key relations.';
15
    }
16
17
    public function up(Schema $schema): void
18
    {
19
        $this->addSql(<<<'SQL'
20
            ALTER TABLE stu_deals ADD CONSTRAINT FK_6DAE42FC4448F8DA FOREIGN KEY (faction_id) REFERENCES stu_factions (id) NOT DEFERRABLE INITIALLY IMMEDIATE
21
        SQL);
22
        $this->addSql(<<<'SQL'
23
            CREATE INDEX IDX_6DAE42FC4448F8DA ON stu_deals (faction_id)
24
        SQL);
25
        $this->addSql(<<<'SQL'
26
            ALTER INDEX planet_type_idx RENAME TO IDX_5C1857F8506FDB14
27
        SQL);
28
        $this->addSql(<<<'SQL'
29
            ALTER TABLE stu_user ALTER race DROP NOT NULL
30
        SQL);
31
    }
32
33
    public function down(Schema $schema): void
34
    {
35
        $this->addSql(<<<'SQL'
36
            ALTER TABLE stu_deals DROP CONSTRAINT FK_6DAE42FC4448F8DA
37
        SQL);
38
        $this->addSql(<<<'SQL'
39
            DROP INDEX IDX_6DAE42FC4448F8DA
40
        SQL);
41
        $this->addSql(<<<'SQL'
42
            ALTER TABLE stu_user ALTER race SET NOT NULL
43
        SQL);
44
        $this->addSql(<<<'SQL'
45
            ALTER INDEX idx_5c1857f8506fdb14 RENAME TO planet_type_idx
46
        SQL);
47
    }
48
}
49