Passed
Push — master ( 363d10...cccee7 )
by Julito
11:08
created

Version20211008133540   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 25
rs 10
c 1
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescription() 0 3 1
A down() 0 2 1
A up() 0 12 4
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 Version20211008133540 extends AbstractMigrationChamilo
11
{
12
    public function getDescription(): string
13
    {
14
        return 'c_tool_intro';
15
    }
16
17
    public function up(Schema $schema): void
18
    {
19
        $table = $schema->getTable('c_tool_intro');
20
21
        if ($table->hasColumn('c_tool_id')) {
22
            if (!$table->hasForeignKey('FK_D705267B1DF6B517')) {
23
                $this->addSql(
24
                    'ALTER TABLE c_tool_intro ADD CONSTRAINT FK_D705267B1DF6B517 FOREIGN KEY (c_tool_id) REFERENCES c_tool (iid);'
25
                );
26
            }
27
            if (!$table->hasIndex('IDX_D705267B1DF6B517')) {
28
                $this->addSql('CREATE INDEX IDX_D705267B1DF6B517 ON c_tool_intro (c_tool_id);');
29
            }
30
        }
31
    }
32
33
    public function down(Schema $schema): void
34
    {
35
    }
36
}
37