Passed
Pull Request — master (#1887)
by Janko
53:41
created

Version20240822091021_LotteryWinnerBuildplan   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 18
ccs 0
cts 9
cp 0
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescription() 0 3 1
A down() 0 4 1
A up() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Migrations;
6
7
use Doctrine\DBAL\Schema\Schema;
8
use Doctrine\Migrations\AbstractMigration;
9
10
final class Version20240822091021_LotteryWinnerBuildplan extends AbstractMigration
11
{
12
    public function getDescription(): string
13
    {
14
        return 'Adds new entity for ship buildplans that lottery winners get.';
15
    }
16
17
    public function up(Schema $schema): void
18
    {
19
        $this->addSql('CREATE TABLE stu_lottery_buildplan (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, buildplan_id INT NOT NULL, chance INT NOT NULL, PRIMARY KEY(id))');
20
        $this->addSql('CREATE INDEX IDX_E8141D9B8638E4E7 ON stu_lottery_buildplan (buildplan_id)');
21
        $this->addSql('ALTER TABLE stu_lottery_buildplan ADD CONSTRAINT FK_E8141D9B8638E4E7 FOREIGN KEY (buildplan_id) REFERENCES stu_buildplans (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
22
    }
23
24
    public function down(Schema $schema): void
25
    {
26
        $this->addSql('ALTER TABLE stu_lottery_buildplan DROP CONSTRAINT FK_E8141D9B8638E4E7');
27
        $this->addSql('DROP TABLE stu_lottery_buildplan');
28
    }
29
}
30