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

Version20201212114909   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 21
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescription() 0 3 1
A down() 0 6 1
A up() 0 6 1
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