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 Version20200130170401 extends AbstractMigration |
14
|
|
|
{ |
15
|
|
|
public function getDescription() : string |
16
|
|
|
{ |
17
|
|
|
return ''; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
View Code Duplication |
public function up(Schema $schema) : void |
|
|
|
|
21
|
|
|
{ |
22
|
|
|
// this up() migration is auto-generated, please modify it to your needs |
23
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
24
|
|
|
|
25
|
|
|
$this->addSql('ALTER TABLE media__media ADD cdn_flush_identifier VARCHAR(64) DEFAULT NULL'); |
26
|
|
|
$this->addSql('ALTER TABLE media__gallery_media DROP FOREIGN KEY FK_80D4C5414E7AF8F'); |
27
|
|
|
$this->addSql('ALTER TABLE media__gallery_media DROP FOREIGN KEY FK_80D4C541EA9FDD75'); |
28
|
|
|
$this->addSql('ALTER TABLE media__gallery_media ADD CONSTRAINT FK_80D4C5414E7AF8F FOREIGN KEY (gallery_id) REFERENCES media__gallery (id) ON DELETE CASCADE'); |
29
|
|
|
$this->addSql('ALTER TABLE media__gallery_media ADD CONSTRAINT FK_80D4C541EA9FDD75 FOREIGN KEY (media_id) REFERENCES media__media (id) ON DELETE CASCADE'); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
View Code Duplication |
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() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
36
|
|
|
|
37
|
|
|
$this->addSql('ALTER TABLE media__gallery_media DROP FOREIGN KEY FK_80D4C5414E7AF8F'); |
38
|
|
|
$this->addSql('ALTER TABLE media__gallery_media DROP FOREIGN KEY FK_80D4C541EA9FDD75'); |
39
|
|
|
$this->addSql('ALTER TABLE media__gallery_media ADD CONSTRAINT FK_80D4C5414E7AF8F FOREIGN KEY (gallery_id) REFERENCES media__gallery (id)'); |
40
|
|
|
$this->addSql('ALTER TABLE media__gallery_media ADD CONSTRAINT FK_80D4C541EA9FDD75 FOREIGN KEY (media_id) REFERENCES media__media (id)'); |
41
|
|
|
$this->addSql('ALTER TABLE media__media DROP cdn_flush_identifier'); |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.