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 Version20180808050452 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 actors_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
19
|
|
|
$this->addSql('CREATE SEQUENCE actors_contacts_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
20
|
|
|
$this->addSql('CREATE SEQUENCE actors_translations_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
21
|
|
|
$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))'); |
22
|
|
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_DF2BF0E555BCC5E5 ON actors (tmdb_id)'); |
23
|
|
|
$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))'); |
24
|
|
|
$this->addSql('CREATE INDEX IDX_BC98436110DAF24A ON actors_contacts (actor_id)'); |
25
|
|
|
$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))'); |
26
|
|
|
$this->addSql('CREATE INDEX IDX_6070C63710DAF24A ON actors_translations (actor_id)'); |
27
|
|
|
$this->addSql('CREATE UNIQUE INDEX idx_ActorTranslations_locale_actor_id ON actors_translations (locale, actor_id)'); |
28
|
|
|
$this->addSql('ALTER TABLE actors_contacts ADD CONSTRAINT FK_BC98436110DAF24A FOREIGN KEY (actor_id) REFERENCES actors (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
29
|
|
|
$this->addSql('ALTER TABLE actors_translations ADD CONSTRAINT FK_6070C63710DAF24A FOREIGN KEY (actor_id) REFERENCES actors (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function down(Schema $schema) : void |
33
|
|
|
{ |
34
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
35
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); |
36
|
|
|
|
37
|
|
|
$this->addSql('CREATE SCHEMA public'); |
38
|
|
|
$this->addSql('ALTER TABLE actors_contacts DROP CONSTRAINT FK_BC98436110DAF24A'); |
39
|
|
|
$this->addSql('ALTER TABLE actors_translations DROP CONSTRAINT FK_6070C63710DAF24A'); |
40
|
|
|
$this->addSql('DROP SEQUENCE actors_id_seq CASCADE'); |
41
|
|
|
$this->addSql('DROP SEQUENCE actors_contacts_id_seq CASCADE'); |
42
|
|
|
$this->addSql('DROP SEQUENCE actors_translations_id_seq CASCADE'); |
43
|
|
|
$this->addSql('DROP TABLE actors'); |
44
|
|
|
$this->addSql('DROP TABLE actors_contacts'); |
45
|
|
|
$this->addSql('DROP TABLE actors_translations'); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|