Completed
Push — master ( 71eba9...1e1a94 )
by Valentyn
04:31
created

Version20190824185439::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 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
final class Version20190824185439 extends AbstractMigration
11
{
12
    public function up(Schema $schema) : void
13
    {
14
        $this->addSql('CREATE SEQUENCE movie_review_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
15
        $this->addSql('CREATE TABLE movie_review (id INT NOT NULL, answer_to_id INT DEFAULT NULL, movie_id INT NOT NULL, user_id INT NOT NULL, text TEXT NOT NULL, locale VARCHAR(2) NOT NULL, is_review BOOLEAN NOT NULL, PRIMARY KEY(id))');
16
        $this->addSql('CREATE INDEX IDX_80841CB3AB0FA336 ON movie_review (answer_to_id)');
17
        $this->addSql('CREATE INDEX IDX_80841CB38F93B6FC ON movie_review (movie_id)');
18
        $this->addSql('CREATE INDEX IDX_80841CB3A76ED395 ON movie_review (user_id)');
19
        $this->addSql('ALTER TABLE movie_review ADD CONSTRAINT FK_80841CB3AB0FA336 FOREIGN KEY (answer_to_id) REFERENCES movie_review (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
20
        $this->addSql('ALTER TABLE movie_review ADD CONSTRAINT FK_80841CB38F93B6FC FOREIGN KEY (movie_id) REFERENCES movies (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
21
        $this->addSql('ALTER TABLE movie_review ADD CONSTRAINT FK_80841CB3A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
22
    }
23
24
    public function down(Schema $schema) : void
25
    {
26
        $this->addSql('CREATE SCHEMA public');
27
        $this->addSql('ALTER TABLE movie_review DROP CONSTRAINT FK_80841CB3AB0FA336');
28
        $this->addSql('DROP SEQUENCE movie_review_id_seq CASCADE');
29
        $this->addSql('DROP TABLE movie_review');
30
    }
31
}
32