Completed
Pull Request — 2.1 (#1090)
by Paweł
09:07
created

Version20200421112353   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 20
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 9 1
A down() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SWP\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 Version20200421112353 extends AbstractMigration
14
{
15
    public function up(Schema $schema): void
16
    {
17
        // this up() migration is auto-generated, please modify it to your needs
18
        $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
19
20
        $this->addSql('CREATE TABLE swp_article_previous_relative_url (id SERIAL NOT NULL, article_id INT DEFAULT NULL, relative_url VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
21
        $this->addSql('CREATE INDEX IDX_52DAEC0F7294869C ON swp_article_previous_relative_url (article_id)');
22
        $this->addSql('ALTER TABLE swp_article_previous_relative_url ADD CONSTRAINT FK_52DAEC0F7294869C FOREIGN KEY (article_id) REFERENCES swp_article (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
23
    }
24
25
    public function down(Schema $schema): void
26
    {
27
        // this down() migration is auto-generated, please modify it to your needs
28
        $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
29
30
        $this->addSql('DROP TABLE swp_article_previous_relative_url');
31
    }
32
}
33