Version20180808050452::up()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.6666
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
/**
11
 * Auto-generated Migration: Please modify to your needs!
12
 */
13
final class Version20180808050452 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 actors_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
21
        $this->addSql('CREATE SEQUENCE actors_contacts_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
22
        $this->addSql('CREATE SEQUENCE actors_translations_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
23
        $this->addSql('CREATE TABLE actors (id INT NOT NULL, original_name VARCHAR(100) NOT NULL, photo VARCHAR(255) DEFAULT NULL, imdb_id VARCHAR(20) DEFAULT NULL, birthday DATE DEFAULT NULL, gender INT NOT NULL, tmdb_id INT NOT NULL, PRIMARY KEY(id))');
24
        $this->addSql('CREATE UNIQUE INDEX UNIQ_DF2BF0E555BCC5E5 ON actors (tmdb_id)');
25
        $this->addSql('CREATE TABLE actors_contacts (id INT NOT NULL, actor_id INT NOT NULL, provider VARCHAR(30) NOT NULL, url VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
26
        $this->addSql('CREATE INDEX IDX_BC98436110DAF24A ON actors_contacts (actor_id)');
27
        $this->addSql('CREATE TABLE actors_translations (id INT NOT NULL, actor_id INT NOT NULL, locale VARCHAR(5) NOT NULL, name VARCHAR(100) NOT NULL, place_of_birth VARCHAR(100) DEFAULT NULL, biography TEXT DEFAULT NULL, PRIMARY KEY(id))');
28
        $this->addSql('CREATE INDEX IDX_6070C63710DAF24A ON actors_translations (actor_id)');
29
        $this->addSql('CREATE UNIQUE INDEX idx_ActorTranslations_locale_actor_id ON actors_translations (locale, actor_id)');
30
        $this->addSql('ALTER TABLE actors_contacts ADD CONSTRAINT FK_BC98436110DAF24A FOREIGN KEY (actor_id) REFERENCES actors (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
31
        $this->addSql('ALTER TABLE actors_translations ADD CONSTRAINT FK_6070C63710DAF24A FOREIGN KEY (actor_id) REFERENCES actors (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
32
    }
33
34
    public function down(Schema $schema): void
35
    {
36
        // this down() migration is auto-generated, please modify it to your needs
37
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
38
39
        $this->addSql('CREATE SCHEMA public');
40
        $this->addSql('ALTER TABLE actors_contacts DROP CONSTRAINT FK_BC98436110DAF24A');
41
        $this->addSql('ALTER TABLE actors_translations DROP CONSTRAINT FK_6070C63710DAF24A');
42
        $this->addSql('DROP SEQUENCE actors_id_seq CASCADE');
43
        $this->addSql('DROP SEQUENCE actors_contacts_id_seq CASCADE');
44
        $this->addSql('DROP SEQUENCE actors_translations_id_seq CASCADE');
45
        $this->addSql('DROP TABLE actors');
46
        $this->addSql('DROP TABLE actors_contacts');
47
        $this->addSql('DROP TABLE actors_translations');
48
    }
49
}
50