Passed
Push — dev ( 12e9d6...f3475b )
by Nico
35:27
created

Version20240805154609::getDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
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
11
final class Version20240805154609 extends AbstractMigration
12
{
13
    public function getDescription(): string
14
    {
15
        return 'Add LocationMining Entity';
16
    }
17
18
    public function up(Schema $schema): void
19
    {
20
21
        $this->addSql('CREATE TABLE stu_location_mining (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, location_id INT NOT NULL, commodity_id INT NOT NULL, actual_amount INT NOT NULL, max_amount INT NOT NULL, depleted_at INT DEFAULT NULL, PRIMARY KEY(id))');
22
        $this->addSql('CREATE INDEX IDX_AC85C1AC64D218E ON stu_location_mining (location_id)');
23
        $this->addSql('CREATE INDEX IDX_AC85C1ACB4ACC212 ON stu_location_mining (commodity_id)');
24
        $this->addSql('ALTER TABLE stu_location_mining ADD CONSTRAINT FK_AC85C1AC64D218E FOREIGN KEY (location_id) REFERENCES stu_location (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
25
        $this->addSql('ALTER TABLE stu_location_mining ADD CONSTRAINT FK_AC85C1ACB4ACC212 FOREIGN KEY (commodity_id) REFERENCES stu_commodity (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
26
    }
27
28
    public function down(Schema $schema): void
29
    {
30
31
        $this->addSql('CREATE SCHEMA public');
32
        $this->addSql('ALTER TABLE stu_location_mining DROP CONSTRAINT FK_AC85C1AC64D218E');
33
        $this->addSql('ALTER TABLE stu_location_mining DROP CONSTRAINT FK_AC85C1ACB4ACC212');
34
        $this->addSql('DROP TABLE stu_location_mining');
35
    }
36
}
37