Version20180808054903   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 13 1
A down() 0 9 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 Version20180808054903 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('CREATE SEQUENCE movies_actors_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
21
        $this->addSql('CREATE TABLE movies_actors (id INT NOT NULL, movie_id INT NOT NULL, actor_id INT NOT NULL, PRIMARY KEY(id))');
22
        $this->addSql('CREATE INDEX IDX_A85722518F93B6FC ON movies_actors (movie_id)');
23
        $this->addSql('CREATE INDEX IDX_A857225110DAF24A ON movies_actors (actor_id)');
24
        $this->addSql('CREATE UNIQUE INDEX Movie_id_Actor_id ON movies_actors (movie_id, actor_id)');
25
        $this->addSql('ALTER TABLE movies_actors ADD CONSTRAINT FK_A85722518F93B6FC FOREIGN KEY (movie_id) REFERENCES movies (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
26
        $this->addSql('ALTER TABLE movies_actors ADD CONSTRAINT FK_A857225110DAF24A FOREIGN KEY (actor_id) REFERENCES actors (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
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($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
33
34
        $this->addSql('CREATE SCHEMA public');
35
        $this->addSql('DROP SEQUENCE movies_actors_id_seq CASCADE');
36
        $this->addSql('DROP TABLE movies_actors');
37
    }
38
}
39