Passed
Push — master ( df16e4...50087e )
by Nico
27:13 queued 16:48
created

Version20241203174248_WormholeRestrictions::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 8
rs 10
c 1
b 0
f 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
11
final class Version20241203174248_WormholeRestrictions extends AbstractMigration
12
{
13
    public function getDescription(): string
14
    {
15
        return 'Add Wormhole Restrictions';
16
    }
17
18
    public function up(Schema $schema): void
19
    {
20
21
        $this->addSql('CREATE TABLE stu_wormhole_restrictions (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, mode INT DEFAULT NULL, wormhole_entry_id INT DEFAULT NULL, user_id INT DEFAULT NULL, PRIMARY KEY(id))');
22
        $this->addSql('CREATE INDEX IDX_76C7B8E0BE56147A ON stu_wormhole_restrictions (wormhole_entry_id)');
23
        $this->addSql('CREATE INDEX IDX_76C7B8E0A76ED395 ON stu_wormhole_restrictions (user_id)');
24
        $this->addSql('ALTER TABLE stu_wormhole_restrictions ADD CONSTRAINT FK_76C7B8E0BE56147A FOREIGN KEY (wormhole_entry_id) REFERENCES stu_wormhole_entry (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
25
        $this->addSql('ALTER TABLE stu_wormhole_restrictions ADD CONSTRAINT FK_76C7B8E0A76ED395 FOREIGN KEY (user_id) REFERENCES stu_user (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
26
    }
27
28
    public function down(Schema $schema): void
29
    {
30
31
        $this->addSql('ALTER TABLE stu_wormhole_restrictions DROP CONSTRAINT FK_76C7B8E0BE56147A');
32
        $this->addSql('ALTER TABLE stu_wormhole_restrictions DROP CONSTRAINT FK_76C7B8E0A76ED395');
33
        $this->addSql('DROP TABLE stu_wormhole_restrictions');
34
    }
35
}
36