Passed
Push — master ( 017cdc...ca97c4 )
by Yannick
08:28
created

Version20250118000100::getDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
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 Version20250118000100 extends AbstractMigrationChamilo
11
{
12
    public function getDescription(): string
13
    {
14
        return 'Add custom_image_id field to c_link table and set up the foreign key to asset table.';
15
    }
16
17
    public function up(Schema $schema): void
18
    {
19
        // Add the new column and foreign key
20
        $this->addSql('
21
            ALTER TABLE c_link
22
            ADD custom_image_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\',
23
            ADD CONSTRAINT FK_9209C2A0D877C209 FOREIGN KEY (custom_image_id) REFERENCES asset (id) ON DELETE SET NULL
24
        ');
25
    }
26
27
    public function down(Schema $schema): void
28
    {
29
        // Remove the custom_image_id column and foreign key
30
        $this->addSql('
31
            ALTER TABLE c_link
32
            DROP FOREIGN KEY FK_9209C2A0D877C209,
33
            DROP custom_image_id
34
        ');
35
    }
36
}
37