Completed
Push — master ( c5110b...a167e6 )
by Valentyn
13:46
created

Version20181030093922   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 14 1
A down() 0 15 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DoctrineMigrations;
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 Version20181030093922 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($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
19
20
        $this->addSql('ALTER TABLE movies_release_dates DROP CONSTRAINT fk_69ecf815f026bb7c');
21
        $this->addSql('DROP INDEX idx_69ecf815f026bb7c');
22
        $this->addSql('DROP INDEX movie_id_country_code');
23
        $this->addSql('ALTER TABLE movies_release_dates ADD country_id INT NOT NULL');
24
        $this->addSql('ALTER TABLE movies_release_dates DROP country_code');
25
        $this->addSql('ALTER TABLE movies_release_dates ADD CONSTRAINT FK_69ECF815F92F3E70 FOREIGN KEY (country_id) REFERENCES countries (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
26
        $this->addSql('CREATE INDEX IDX_69ECF815F92F3E70 ON movies_release_dates (country_id)');
27
        $this->addSql('CREATE UNIQUE INDEX Movie_id_Country_id ON movies_release_dates (movie_id, country_id)');
28
    }
29
30
    public function down(Schema $schema): void
31
    {
32
        // this down() migration is auto-generated, please modify it to your needs
33
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
34
35
        $this->addSql('CREATE SCHEMA public');
36
        $this->addSql('ALTER TABLE movies_release_dates DROP CONSTRAINT FK_69ECF815F92F3E70');
37
        $this->addSql('DROP INDEX IDX_69ECF815F92F3E70');
38
        $this->addSql('DROP INDEX Movie_id_Country_id');
39
        $this->addSql('ALTER TABLE movies_release_dates ADD country_code VARCHAR(3) NOT NULL');
40
        $this->addSql('ALTER TABLE movies_release_dates DROP country_id');
41
        $this->addSql('ALTER TABLE movies_release_dates ADD CONSTRAINT fk_69ecf815f026bb7c FOREIGN KEY (country_code) REFERENCES countries (code) NOT DEFERRABLE INITIALLY IMMEDIATE');
42
        $this->addSql('CREATE INDEX idx_69ecf815f026bb7c ON movies_release_dates (country_code)');
43
        $this->addSql('CREATE UNIQUE INDEX movie_id_country_code ON movies_release_dates (movie_id, country_code)');
44
    }
45
}
46