Version20190303200340::up()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 13
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Migrations;
6
7
use Doctrine\DBAL\Schema\Schema;
8
use Doctrine\Migrations\AbstractMigration;
9
10
/**
11
 * Auto-generated Migration: Please modify to your needs!
12
 */
13
final class Version20190303200340 extends AbstractMigration
14
{
15
    public function getDescription(): string
16
    {
17
        return '';
18
    }
19
20
    public function up(Schema $schema): void
21
    {
22
        // this up() migration is auto-generated, please modify it to your needs
23
        $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
24
25
        $this->addSql('ALTER TABLE npd_user ADD password_need_to_be_changed BOOLEAN DEFAULT NULL');
26
        $this->addSql('ALTER TABLE user_course DROP CONSTRAINT FK_73CC7484A76ED395');
27
        $this->addSql('ALTER TABLE user_course DROP CONSTRAINT FK_73CC7484591CC992');
28
        $this->addSql('ALTER TABLE 
29
          user_course 
30
        ADD 
31
          CONSTRAINT FK_73CC7484A76ED395 FOREIGN KEY (user_id) REFERENCES npd_user (uuid) NOT DEFERRABLE INITIALLY IMMEDIATE');
32
        $this->addSql('ALTER TABLE 
33
          user_course 
34
        ADD 
35
          CONSTRAINT FK_73CC7484591CC992 FOREIGN KEY (course_id) REFERENCES course (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
36
    }
37
38
    public function down(Schema $schema): void
39
    {
40
        // this down() migration is auto-generated, please modify it to your needs
41
        $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
42
43
        $this->addSql('ALTER TABLE user_course DROP CONSTRAINT fk_73cc7484a76ed395');
44
        $this->addSql('ALTER TABLE user_course DROP CONSTRAINT fk_73cc7484591cc992');
45
        $this->addSql('ALTER TABLE 
46
          user_course 
47
        ADD 
48
          CONSTRAINT fk_73cc7484a76ed395 FOREIGN KEY (user_id) REFERENCES npd_user (uuid) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
49
        $this->addSql('ALTER TABLE 
50
          user_course 
51
        ADD 
52
          CONSTRAINT fk_73cc7484591cc992 FOREIGN KEY (course_id) REFERENCES course (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
53
        $this->addSql('ALTER TABLE npd_user DROP password_need_to_be_changed');
54
    }
55
}
56