Passed
Push — master ( dc0b89...206b37 )
by Nico
12:39
created

Version20250526153605_HistoryWithLocation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 20
dl 0
loc 29
rs 10
c 1
b 0
f 1
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 9 1
A down() 0 9 1
A getDescription() 0 3 1
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 Version20250526153605_HistoryWithLocation extends AbstractMigration
11
{
12
    public function getDescription(): string
13
    {
14
        return 'Adds optional location reference to history entries.';
15
    }
16
17
    public function up(Schema $schema): void
18
    {
19
        $this->addSql(<<<'SQL'
20
            ALTER TABLE stu_history ADD location_id INT DEFAULT NULL
21
        SQL);
22
        $this->addSql(<<<'SQL'
23
            ALTER TABLE stu_history ADD CONSTRAINT FK_7F01683964D218E FOREIGN KEY (location_id) REFERENCES stu_location (id) NOT DEFERRABLE INITIALLY IMMEDIATE
24
        SQL);
25
        $this->addSql(<<<'SQL'
26
            CREATE INDEX IDX_7F01683964D218E ON stu_history (location_id)
27
        SQL);
28
    }
29
30
    public function down(Schema $schema): void
31
    {
32
        $this->addSql(<<<'SQL'
33
            ALTER TABLE stu_history DROP CONSTRAINT FK_7F01683964D218E
34
        SQL);
35
        $this->addSql(<<<'SQL'
36
            DROP INDEX IDX_7F01683964D218E
37
        SQL);
38
        $this->addSql(<<<'SQL'
39
            ALTER TABLE stu_history DROP location_id
40
        SQL);
41
    }
42
}
43