Version20210401194805   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 8 1
A down() 0 10 1
A getDescription() 0 3 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 Version20210401194805 extends AbstractMigration
14
{
15
    public function getDescription() : string
16
    {
17
        return '';
18
    }
19
20
    public function up(Schema $schema) : void
21
    {
22
        // this up() migration is auto-generated, please modify it to your needs
23
        $this->addSql('ALTER TABLE image ADD wander_id INT DEFAULT NULL');
24
        $this->addSql('ALTER TABLE image ADD CONSTRAINT FK_C53D045F2F82EC6B FOREIGN KEY (wander_id) REFERENCES wander (id)');
25
        $this->addSql('CREATE INDEX IDX_C53D045F2F82EC6B ON image (wander_id)');
26
        $this->addSql('UPDATE image INNER JOIN wander_image ON image.id = wander_image.image_id SET image.wander_id = wander_image.wander_id');
27
        $this->addSql('DROP TABLE wander_image');
28
    }
29
30
    public function down(Schema $schema) : void
31
    {
32
        // this down() migration is auto-generated, please modify it to your needs
33
        $this->addSql('CREATE TABLE wander_image (wander_id INT NOT NULL, image_id INT NOT NULL, INDEX IDX_69C7253A2F82EC6B (wander_id), INDEX IDX_69C7253A3DA5256D (image_id), PRIMARY KEY(wander_id, image_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
34
        $this->addSQL('INSERT INTO wander_image (wander_id, image_id) SELECT wander_id, id FROM image');
35
        $this->addSql('ALTER TABLE wander_image ADD CONSTRAINT FK_69C7253A2F82EC6B FOREIGN KEY (wander_id) REFERENCES wander (id) ON UPDATE NO ACTION ON DELETE CASCADE');
36
        $this->addSql('ALTER TABLE wander_image ADD CONSTRAINT FK_69C7253A3DA5256D FOREIGN KEY (image_id) REFERENCES image (id) ON UPDATE NO ACTION ON DELETE CASCADE');
37
        $this->addSql('ALTER TABLE image DROP FOREIGN KEY FK_C53D045F2F82EC6B');
38
        $this->addSql('DROP INDEX IDX_C53D045F2F82EC6B ON image');
39
        $this->addSql('ALTER TABLE image DROP wander_id');
40
    }
41
}
42