Passed
Pull Request — dev (#2038)
by Janko
09:06
created

Version20250114140100::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
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 Version20250114140100 extends AbstractMigration
11
{
12
    public function getDescription(): string
13
    {
14
        return 'Rename crew attribute type to rank.';
15
    }
16
17
    public function up(Schema $schema): void
18
    {
19
        $this->addSql('ALTER TABLE stu_crew ADD rank VARCHAR(255) DEFAULT NULL');
20
        $this->addSql(sprintf('UPDATE stu_crew set rank = \'RECRUIT\''));
21
        $this->addSql('ALTER TABLE stu_crew ALTER rank SET NOT NULL');
22
        $this->addSql('ALTER TABLE stu_crew DROP type');
23
    }
24
25
    public function down(Schema $schema): void
26
    {
27
        $this->addSql('ALTER TABLE stu_crew ADD type SMALLINT NOT NULL');
28
        $this->addSql('ALTER TABLE stu_crew DROP rank');
29
    }
30
}
31