Passed
Push — master ( ba5bfe...989b97 )
by Angel Fernando Quiroz
09:49 queued 40s
created

Version20201212114909::getDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
6
7
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
8
use Doctrine\DBAL\Schema\Schema;
9
10
final class Version20201212114909 extends AbstractMigrationChamilo
11
{
12
    public function getDescription() : string
13
    {
14
        return 'Add image_id field to templates table to link with asset table';
15
    }
16
17
    public function up(Schema $schema) : void
18
    {
19
        // this up() migration is auto-generated, please modify it to your needs
20
        $this->addSql('ALTER TABLE templates ADD image_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
21
        $this->addSql('ALTER TABLE templates ADD CONSTRAINT FK_6F287D8E3DA5256D FOREIGN KEY (image_id) REFERENCES asset (id) ON DELETE SET NULL');
22
        $this->addSql('CREATE INDEX IDX_6F287D8E3DA5256D ON templates (image_id)');
23
    }
24
25
    public function down(Schema $schema) : void
26
    {
27
        // this down() migration is auto-generated, please modify it to your needs
28
        $this->addSql('ALTER TABLE templates DROP FOREIGN KEY FK_6F287D8E3DA5256D');
29
        $this->addSql('DROP INDEX IDX_6F287D8E3DA5256D ON templates');
30
        $this->addSql('ALTER TABLE templates DROP image_id');
31
    }
32
}
33