Completed
Push — master ( 3d822c...064d2b )
by Valentyn
32:01
created

Version20180912064422   A

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 declare(strict_types=1);
2
3
namespace DoctrineMigrations;
4
5
use Doctrine\DBAL\Schema\Schema;
6
use Doctrine\Migrations\AbstractMigration;
7
8
/**
9
 * Auto-generated Migration: Please modify to your needs!
10
 */
11
final class Version20180912064422 extends AbstractMigration
12
{
13
    public function up(Schema $schema) : void
14
    {
15
        // this up() migration is auto-generated, please modify it to your needs
16
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
17
18
        $this->addSql('CREATE SEQUENCE users_interested_movies_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
19
        $this->addSql('CREATE TABLE users_interested_movies (id INT NOT NULL, user_id INT NOT NULL, movie_id INT NOT NULL, PRIMARY KEY(id))');
20
        $this->addSql('CREATE INDEX IDX_F2A24D01A76ED395 ON users_interested_movies (user_id)');
21
        $this->addSql('CREATE INDEX IDX_F2A24D018F93B6FC ON users_interested_movies (movie_id)');
22
        $this->addSql('CREATE UNIQUE INDEX idx_UserInterestedMovie_user_id_movie_id ON users_interested_movies (user_id, movie_id)');
23
        $this->addSql('ALTER TABLE users_interested_movies ADD CONSTRAINT FK_F2A24D01A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
24
        $this->addSql('ALTER TABLE users_interested_movies ADD CONSTRAINT FK_F2A24D018F93B6FC FOREIGN KEY (movie_id) REFERENCES movies (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
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($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
31
32
        $this->addSql('CREATE SCHEMA public');
33
        $this->addSql('DROP SEQUENCE users_interested_movies_id_seq CASCADE');
34
        $this->addSql('DROP TABLE users_interested_movies');
35
    }
36
}
37