Version20200529034907::getDescription()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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
final class Version20200529034907 extends AbstractMigration
11
{
12
    public function getDescription(): string
13
    {
14
        return 'Allow removing already read notification';
15
    }
16
17
    public function up(Schema $schema): void
18
    {
19
        $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
20
21
        $this->addSql('ALTER TABLE npd_user_read_notifications DROP CONSTRAINT FK_62224523A76ED395');
22
        $this->addSql('ALTER TABLE npd_user_read_notifications DROP CONSTRAINT FK_62224523EF1A9D84');
23
        $this->addSql('ALTER TABLE 
24
          npd_user_read_notifications 
25
        ADD 
26
          CONSTRAINT FK_62224523A76ED395 FOREIGN KEY (user_id) REFERENCES npd_user (uuid) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
27
        $this->addSql('ALTER TABLE 
28
          npd_user_read_notifications 
29
        ADD 
30
          CONSTRAINT FK_62224523EF1A9D84 FOREIGN KEY (notification_id) REFERENCES npd_notification (uuid) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
31
    }
32
33
    public function down(Schema $schema): void
34
    {
35
        // this down() migration is auto-generated, please modify it to your needs
36
        $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
37
38
        $this->addSql('ALTER TABLE npd_user_read_notifications DROP CONSTRAINT fk_62224523a76ed395');
39
        $this->addSql('ALTER TABLE npd_user_read_notifications DROP CONSTRAINT fk_62224523ef1a9d84');
40
        $this->addSql('ALTER TABLE 
41
          npd_user_read_notifications 
42
        ADD 
43
          CONSTRAINT fk_62224523a76ed395 FOREIGN KEY (user_id) REFERENCES npd_user (uuid) NOT DEFERRABLE INITIALLY IMMEDIATE');
44
        $this->addSql('ALTER TABLE 
45
          npd_user_read_notifications 
46
        ADD 
47
          CONSTRAINT fk_62224523ef1a9d84 FOREIGN KEY (notification_id) REFERENCES npd_notification (uuid) NOT DEFERRABLE INITIALLY IMMEDIATE');
48
    }
49
}
50