Passed
Pull Request — master (#2138)
by Nico
25:02 queued 13:24
created

Version20250610150652   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 23
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 9 1
A getDescription() 0 3 1
A down() 0 12 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 Version20250610150652 extends AbstractMigration
11
{
12
    public function getDescription(): string
13
    {
14
        return 'Reset the primary key of crew assignments.';
15
    }
16
17
    public function up(Schema $schema): void
18
    {
19
        $this->addSql(<<<'SQL'
20
            DROP INDEX crew_assign_crew_idx
21
        SQL);
22
        $this->addSql(<<<'SQL'
23
            ALTER TABLE stu_crew_assign DROP id
24
        SQL);
25
        $this->addSql(<<<'SQL'
26
            ALTER TABLE stu_crew_assign ADD PRIMARY KEY (crew_id)
27
        SQL);
28
    }
29
30
    public function down(Schema $schema): void
31
    {
32
        $this->addSql(<<<'SQL'
33
            DROP INDEX idx_223179_primary
34
        SQL);
35
        $this->addSql(<<<'SQL'
36
            ALTER TABLE stu_crew_assign ADD id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL
37
        SQL);
38
        $this->addSql(<<<'SQL'
39
            CREATE UNIQUE INDEX crew_assign_crew_idx ON stu_crew_assign (crew_id)
40
        SQL);
41
        $this->addSql(<<<'SQL'
42
            ALTER TABLE stu_crew_assign ADD PRIMARY KEY (id)
43
        SQL);
44
    }
45
}
46