Completed
Pull Request — 2.0 (#981)
by Rafał
08:59
created

Version20191021123527   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 11 11 1
A down() 8 8 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 Version20191021123527 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('DELETE FROM swp_article_media USING swp_slideshow_item WHERE swp_article_media.id = swp_slideshow_item.article_media_id AND swp_slideshow_item.deleted_at IS NOT NULL');
21
        $this->addSql('DELETE FROM swp_slideshow_item WHERE deleted_at IS NOT NULL');
22
        $this->addSql('DELETE FROM swp_slideshow WHERE deleted_at IS NOT NULL');
23
        $this->addSql('ALTER TABLE swp_slideshow_item DROP deleted_at');
24
        $this->addSql('ALTER TABLE swp_slideshow DROP deleted_at');
25
    }
26
27
    public function down(Schema $schema): void
28
    {
29
        // this down() migration is auto-generated, please modify it to your needs
30
        $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
31
32
        $this->addSql('ALTER TABLE swp_slideshow_item ADD deleted_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
33
        $this->addSql('ALTER TABLE swp_slideshow ADD deleted_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
34
    }
35
}
36