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
|
|
|
final class Version20180614071345 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('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); |
19
|
|
|
|
20
|
|
|
$this->addSql('CREATE TABLE swp_author_media ( |
21
|
|
|
id SERIAL NOT NULL, |
22
|
|
|
author_id INT DEFAULT NULL, |
23
|
|
|
file_id INT DEFAULT NULL, |
24
|
|
|
image_id INT DEFAULT NULL, |
25
|
|
|
key VARCHAR(255) NOT NULL, |
26
|
|
|
created_at DATE NOT NULL, |
27
|
|
|
updated_at DATE DEFAULT NULL, |
28
|
|
|
PRIMARY KEY(id) |
29
|
|
|
)'); |
30
|
|
|
$this->addSql('CREATE INDEX IDX_44AC8FA7F675F31B ON swp_author_media (author_id)'); |
31
|
|
|
$this->addSql('CREATE INDEX IDX_44AC8FA793CB796C ON swp_author_media (file_id)'); |
32
|
|
|
$this->addSql('CREATE INDEX IDX_44AC8FA73DA5256D ON swp_author_media (image_id)'); |
33
|
|
|
$this->addSql('ALTER TABLE |
34
|
|
|
swp_author_media |
35
|
|
|
ADD |
36
|
|
|
CONSTRAINT FK_44AC8FA7F675F31B FOREIGN KEY (author_id) REFERENCES swp_author (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
37
|
|
|
$this->addSql('ALTER TABLE |
38
|
|
|
swp_author_media |
39
|
|
|
ADD |
40
|
|
|
CONSTRAINT FK_44AC8FA793CB796C FOREIGN KEY (file_id) REFERENCES swp_file (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
41
|
|
|
$this->addSql('ALTER TABLE |
42
|
|
|
swp_author_media |
43
|
|
|
ADD |
44
|
|
|
CONSTRAINT FK_44AC8FA73DA5256D FOREIGN KEY (image_id) REFERENCES swp_image (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
45
|
|
|
$this->addSql('ALTER TABLE swp_author ADD author_media_id INT DEFAULT NULL'); |
46
|
|
|
$this->addSql('ALTER TABLE |
47
|
|
|
swp_author |
48
|
|
|
ADD |
49
|
|
|
CONSTRAINT FK_1F96895450FF7C0 FOREIGN KEY (author_media_id) REFERENCES swp_author_media (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
50
|
|
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_1F96895450FF7C0 ON swp_author (author_media_id)'); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function down(Schema $schema): void |
54
|
|
|
{ |
55
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
56
|
|
|
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); |
57
|
|
|
|
58
|
|
|
$this->addSql('ALTER TABLE swp_author DROP CONSTRAINT FK_1F96895450FF7C0'); |
59
|
|
|
$this->addSql('DROP TABLE swp_author_media'); |
60
|
|
|
$this->addSql('DROP INDEX UNIQ_1F96895450FF7C0'); |
61
|
|
|
$this->addSql('ALTER TABLE swp_author DROP author_media_id'); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
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.