1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SWP\Migrations; |
6
|
|
|
|
7
|
|
|
use Doctrine\DBAL\Migrations\AbstractMigration; |
8
|
|
|
use Doctrine\DBAL\Schema\Schema; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Auto-generated Migration: Please modify to your needs! |
12
|
|
|
*/ |
13
|
|
View Code Duplication |
class Version20180122115426 extends AbstractMigration |
|
|
|
|
14
|
|
|
{ |
15
|
|
|
public function up(Schema $schema) |
16
|
|
|
{ |
17
|
|
|
// this up() migration is auto-generated, please modify it to your needs |
18
|
|
|
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); |
19
|
|
|
|
20
|
|
|
$this->addSql('CREATE SEQUENCE swp_author_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
21
|
|
|
$this->addSql('CREATE TABLE swp_author (id INT NOT NULL, name VARCHAR(255) NOT NULL, role VARCHAR(255) NOT NULL, biography VARCHAR(255) DEFAULT NULL, job_title TEXT NOT NULL, PRIMARY KEY(id))'); |
22
|
|
|
$this->addSql('COMMENT ON COLUMN swp_author.job_title IS \'(DC2Type:array)\''); |
23
|
|
|
$this->addSql('CREATE TABLE swp_package_author (package_id INT NOT NULL, author_id INT NOT NULL, PRIMARY KEY(package_id, author_id))'); |
24
|
|
|
$this->addSql('CREATE INDEX IDX_574B723AF44CABFF ON swp_package_author (package_id)'); |
25
|
|
|
$this->addSql('CREATE INDEX IDX_574B723AF675F31B ON swp_package_author (author_id)'); |
26
|
|
|
$this->addSql('CREATE TABLE swp_article_author (article_id INT NOT NULL, author_id INT NOT NULL, PRIMARY KEY(article_id, author_id))'); |
27
|
|
|
$this->addSql('CREATE INDEX IDX_37796667294869C ON swp_article_author (article_id)'); |
28
|
|
|
$this->addSql('CREATE INDEX IDX_3779666F675F31B ON swp_article_author (author_id)'); |
29
|
|
|
$this->addSql('ALTER TABLE swp_package_author ADD CONSTRAINT FK_574B723AF44CABFF FOREIGN KEY (package_id) REFERENCES swp_package (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
30
|
|
|
$this->addSql('ALTER TABLE swp_package_author ADD CONSTRAINT FK_574B723AF675F31B FOREIGN KEY (author_id) REFERENCES swp_author (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
31
|
|
|
$this->addSql('ALTER TABLE swp_article_author ADD CONSTRAINT FK_37796667294869C FOREIGN KEY (article_id) REFERENCES swp_article (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
32
|
|
|
$this->addSql('ALTER TABLE swp_article_author ADD CONSTRAINT FK_3779666F675F31B FOREIGN KEY (author_id) REFERENCES swp_author (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function down(Schema $schema) |
36
|
|
|
{ |
37
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
38
|
|
|
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); |
39
|
|
|
|
40
|
|
|
$this->addSql('ALTER TABLE swp_package_author DROP CONSTRAINT FK_574B723AF675F31B'); |
41
|
|
|
$this->addSql('ALTER TABLE swp_article_author DROP CONSTRAINT FK_3779666F675F31B'); |
42
|
|
|
$this->addSql('DROP SEQUENCE swp_author_id_seq CASCADE'); |
43
|
|
|
$this->addSql('DROP TABLE swp_author'); |
44
|
|
|
$this->addSql('DROP TABLE swp_package_author'); |
45
|
|
|
$this->addSql('DROP TABLE swp_article_author'); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.