Completed
Push — master ( ffddc8...a95708 )
by Rafał
09:43
created

Version20200331075145   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 17 17 1
A down() 15 15 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 View Code Duplication
final class Version20200331075145 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 SEQUENCE swp_apple_news_config_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
21
        $this->addSql('CREATE SEQUENCE swp_article_apple_news_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
22
        $this->addSql('CREATE TABLE swp_apple_news_config (id INT NOT NULL, tenant_id INT DEFAULT NULL, channel_id VARCHAR(255) NOT NULL, api_key_id VARCHAR(255) NOT NULL, api_key_secret VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
23
        $this->addSql('CREATE UNIQUE INDEX UNIQ_C308F3089033212A ON swp_apple_news_config (tenant_id)');
24
        $this->addSql('CREATE TABLE swp_article_apple_news (id INT NOT NULL, apple_news_article_id VARCHAR(255) NOT NULL, revision_id VARCHAR(255) NOT NULL, share_url VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
25
        $this->addSql('ALTER TABLE swp_apple_news_config ADD CONSTRAINT FK_C308F3089033212A FOREIGN KEY (tenant_id) REFERENCES swp_tenant (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
26
        $this->addSql('ALTER TABLE swp_article ADD apple_news_article_id INT DEFAULT NULL');
27
        $this->addSql('ALTER TABLE swp_article ADD is_published_to_apple_news BOOLEAN DEFAULT \'false\' NOT NULL');
28
        $this->addSql('ALTER TABLE swp_article ADD CONSTRAINT FK_FB21E858790923B6 FOREIGN KEY (apple_news_article_id) REFERENCES swp_article_apple_news (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
29
        $this->addSql('CREATE UNIQUE INDEX UNIQ_FB21E858790923B6 ON swp_article (apple_news_article_id)');
30
        $this->addSql('ALTER TABLE swp_publish_destination ADD is_published_to_apple_news BOOLEAN DEFAULT \'false\' NOT NULL');
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 swp_article DROP CONSTRAINT FK_FB21E858790923B6');
39
        $this->addSql('DROP SEQUENCE swp_apple_news_config_id_seq CASCADE');
40
        $this->addSql('DROP SEQUENCE swp_article_apple_news_id_seq CASCADE');
41
        $this->addSql('DROP TABLE swp_apple_news_config');
42
        $this->addSql('DROP TABLE swp_article_apple_news');
43
        $this->addSql('DROP INDEX UNIQ_FB21E858790923B6');
44
        $this->addSql('ALTER TABLE swp_article DROP apple_news_article_id');
45
        $this->addSql('ALTER TABLE swp_article DROP is_published_to_apple_news');
46
        $this->addSql('ALTER TABLE swp_publish_destination DROP is_published_to_apple_news');
47
    }
48
}
49