Completed
Push — 1.5 ( dc62f6...bc7363 )
by Rafał
10:57
created

Version20190320142338   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 13 13 1
A down() 13 13 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 Version20190320142338 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('ALTER TABLE swp_item ADD body_text TEXT DEFAULT NULL');
21
        $this->addSql('ALTER TABLE swp_item ADD usage_terms VARCHAR(255) DEFAULT NULL');
22
        $this->addSql('ALTER TABLE swp_item ADD copyright_notice VARCHAR(255) DEFAULT NULL');
23
        $this->addSql('ALTER TABLE swp_item ADD copyright_holder VARCHAR(255) DEFAULT NULL');
24
        $this->addSql('ALTER TABLE swp_article_media ADD headline TEXT DEFAULT NULL');
25
        $this->addSql('ALTER TABLE swp_article_media ADD copyright_notice VARCHAR(255) DEFAULT NULL');
26
        $this->addSql('ALTER TABLE swp_article_media ADD copyright_holder VARCHAR(255) DEFAULT NULL');
27
    }
28
29
    public function down(Schema $schema): void
30
    {
31
        // this down() migration is auto-generated, please modify it to your needs
32
        $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
33
34
        $this->addSql('ALTER TABLE swp_item DROP body_text');
35
        $this->addSql('ALTER TABLE swp_item DROP usage_terms');
36
        $this->addSql('ALTER TABLE swp_item DROP copyright_notice');
37
        $this->addSql('ALTER TABLE swp_item DROP copyright_holder');
38
        $this->addSql('ALTER TABLE swp_article_media DROP headline');
39
        $this->addSql('ALTER TABLE swp_article_media DROP copyright_notice');
40
        $this->addSql('ALTER TABLE swp_article_media DROP copyright_holder');
41
    }
42
}
43