Passed
Push — master ( b3f573...f22e85 )
by Yannick
06:55 queued 13s
created

Version20240114212100::down()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 9
nc 8
nop 1
dl 0
loc 16
rs 9.9666
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 Version20240114212100 extends AbstractMigrationChamilo
11
{
12
    public function getDescription(): string
13
    {
14
        return 'Replace "name" with "title" fields in tables (part 3)';
15
    }
16
17
    public function up(Schema $schema): void
18
    {
19
20
        if ($schema->hasTable('contact_form_contact_category')) {
21
            $this->addSql(
22
                'ALTER TABLE contact_form_contact_category CHANGE name title VARCHAR(255) NOT NULL'
23
            );
24
        }
25
26
        if ($schema->hasTable('fos_group')) {
27
            $this->addSql(
28
                'ALTER TABLE fos_group CHANGE name title VARCHAR(255) NOT NULL'
29
            );
30
        }
31
32
        if ($schema->hasTable('resource_file')) {
33
            $this->addSql(
34
                'ALTER TABLE fos_group CHANGE name title VARCHAR(255) NOT NULL'
35
            );
36
        }
37
38
    }
39
40
    public function down(Schema $schema): void
41
    {
42
43
        $table = $schema->getTable('resource_file');
44
        if ($table->hasColumn('title')) {
45
            $this->addSql('ALTER TABLE resource_file CHANGE title name VARCHAR(255) NOT NULL');
46
        }
47
48
        $table = $schema->getTable('fos_group');
49
        if ($table->hasColumn('title')) {
50
            $this->addSql('ALTER TABLE fos_group CHANGE title name VARCHAR(255) NOT NULL');
51
        }
52
53
        $table = $schema->getTable('contact_form_contact_category');
54
        if ($table->hasColumn('title')) {
55
            $this->addSql('ALTER TABLE contact_form_contact_category CHANGE title name VARCHAR(255) NOT NULL');
56
        }
57
58
    }
59
}
60