Completed
Push — master ( 19732d...076741 )
by Paweł
11:47
created

Version20170908083733   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 54
Duplicated Lines 44.44 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 24 24 1
A down() 0 20 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
namespace SWP\Migrations;
4
5
use Doctrine\DBAL\Migrations\AbstractMigration;
6
use Doctrine\DBAL\Schema\Schema;
7
8
/**
9
 * Auto-generated Migration: Please modify to your needs!
10
 */
11
class Version20170908083733 extends AbstractMigration
0 ignored issues
show
Deprecated Code introduced by
The class Doctrine\DBAL\Migrations\AbstractMigration has been deprecated with message: Please use Doctrine\Migrations\AbstractMigration

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
12
{
13
    /**
14
     * @param Schema $schema
15
     */
16 View Code Duplication
    public function up(Schema $schema)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
    {
18
        // this up() migration is auto-generated, please modify it to your needs
19
        $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
20
21
        $this->addSql('CREATE SEQUENCE swp_event_category_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
22
        $this->addSql('CREATE SEQUENCE swp_event_date_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
23
        $this->addSql('CREATE SEQUENCE swp_event_location_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
24
        $this->addSql('CREATE SEQUENCE swp_event_occur_status_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
25
        $this->addSql('CREATE SEQUENCE swp_event_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
26
        $this->addSql('CREATE TABLE swp_event_category (id INT NOT NULL, event_id INT NOT NULL, name VARCHAR(255) NOT NULL, qcode VARCHAR(255) NOT NULL, subject VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
27
        $this->addSql('CREATE INDEX IDX_94BF293F71F7E88B ON swp_event_category (event_id)');
28
        $this->addSql('CREATE TABLE swp_event_date (id INT NOT NULL, start_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, end_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, tz VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
29
        $this->addSql('CREATE TABLE swp_event_location (id INT NOT NULL, event_id INT NOT NULL, name VARCHAR(255) NOT NULL, qcode VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
30
        $this->addSql('CREATE INDEX IDX_CC6DB93571F7E88B ON swp_event_location (event_id)');
31
        $this->addSql('CREATE TABLE swp_event_occur_status (id INT NOT NULL, name VARCHAR(255) NOT NULL, qcode VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
32
        $this->addSql('CREATE TABLE swp_event (id INT NOT NULL, dates_id INT DEFAULT NULL, occur_status_id INT DEFAULT NULL, etag VARCHAR(255) NOT NULL, guid VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, version INT DEFAULT NULL, ingest_id VARCHAR(255) DEFAULT NULL, recurrence_id VARCHAR(255) DEFAULT NULL, original_creator VARCHAR(255) NOT NULL, version_creator VARCHAR(255) DEFAULT NULL, ingest_provider VARCHAR(255) DEFAULT NULL, original_source VARCHAR(255) DEFAULT NULL, ingest_provider_sequence VARCHAR(255) DEFAULT NULL, definition_short VARCHAR(255) DEFAULT NULL, definition_long VARCHAR(255) DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
33
        $this->addSql('CREATE UNIQUE INDEX UNIQ_658EE4843DA992C3 ON swp_event (dates_id)');
34
        $this->addSql('CREATE UNIQUE INDEX UNIQ_658EE4845DA64DFB ON swp_event (occur_status_id)');
35
        $this->addSql('ALTER TABLE swp_event_category ADD CONSTRAINT FK_94BF293F71F7E88B FOREIGN KEY (event_id) REFERENCES swp_event (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
36
        $this->addSql('ALTER TABLE swp_event_location ADD CONSTRAINT FK_CC6DB93571F7E88B FOREIGN KEY (event_id) REFERENCES swp_event (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
37
        $this->addSql('ALTER TABLE swp_event ADD CONSTRAINT FK_658EE4843DA992C3 FOREIGN KEY (dates_id) REFERENCES swp_event_date (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
38
        $this->addSql('ALTER TABLE swp_event ADD CONSTRAINT FK_658EE4845DA64DFB FOREIGN KEY (occur_status_id) REFERENCES swp_event_occur_status (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
39
    }
40
41
    /**
42
     * @param Schema $schema
43
     */
44
    public function down(Schema $schema)
45
    {
46
        // this down() migration is auto-generated, please modify it to your needs
47
        $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
48
49
        $this->addSql('ALTER TABLE swp_event DROP CONSTRAINT FK_658EE4843DA992C3');
50
        $this->addSql('ALTER TABLE swp_event DROP CONSTRAINT FK_658EE4845DA64DFB');
51
        $this->addSql('ALTER TABLE swp_event_category DROP CONSTRAINT FK_94BF293F71F7E88B');
52
        $this->addSql('ALTER TABLE swp_event_location DROP CONSTRAINT FK_CC6DB93571F7E88B');
53
        $this->addSql('DROP SEQUENCE swp_event_category_id_seq CASCADE');
54
        $this->addSql('DROP SEQUENCE swp_event_date_id_seq CASCADE');
55
        $this->addSql('DROP SEQUENCE swp_event_location_id_seq CASCADE');
56
        $this->addSql('DROP SEQUENCE swp_event_occur_status_id_seq CASCADE');
57
        $this->addSql('DROP SEQUENCE swp_event_id_seq CASCADE');
58
        $this->addSql('DROP TABLE swp_event_category');
59
        $this->addSql('DROP TABLE swp_event_date');
60
        $this->addSql('DROP TABLE swp_event_location');
61
        $this->addSql('DROP TABLE swp_event_occur_status');
62
        $this->addSql('DROP TABLE swp_event');
63
    }
64
}
65