Passed
Pull Request — master (#5143)
by Angel Fernando Quiroz
07:01
created

Version20240313111800::getDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 9
rs 10
c 2
b 0
f 0
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
declare(strict_types=1);
6
7
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
8
9
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
10
use Doctrine\DBAL\Schema\Schema;
11
12
class Version20240313111800 extends AbstractMigrationChamilo
13
{
14
    private array $changes = [
15
        'c_lp' => 'display_order',
16
        'c_lp_category' => 'position',
17
        'c_forum_category' => 'cat_order',
18
        'c_forum_forum' => 'forum_order',
19
        'c_thematic' => 'display_order',
20
        'c_announcement' => 'display_order',
21
        'c_glossary' => 'display_order',
22
    ];
23
24
    public function getDescription(): string
25
    {
26
        $tables = array_keys($this->changes);
27
        $columns = array_values($this->changes);
28
29
        return sprintf(
30
            'Removing %s columns from % tables',
31
            implode(', ', $columns),
32
            implode(', ', $tables)
33
        );
34
    }
35
36
    public function up(Schema $schema): void
37
    {
38
        foreach ($this->changes as $table => $column) {
39
            $this->addSql("ALTER TABLE $table DROP $column");
40
        }
41
    }
42
}
43