Passed
Pull Request — master (#5651)
by Yannick
08:37
created

Version20240709222600   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 6
c 2
b 0
f 0
dl 0
loc 38
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescription() 0 3 1
A up() 0 14 1
A down() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
8
9
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
10
use Doctrine\DBAL\Schema\Schema;
11
12
final class Version20240709222600 extends AbstractMigrationChamilo
13
{
14
    public function getDescription(): string
15
    {
16
        return 'Create permission and permission_rel_role tables';
17
    }
18
19
    public function up(Schema $schema): void
20
    {
21
        $this->addSql('
22
            CREATE TABLE IF NOT EXISTS permission (
23
                id INT AUTO_INCREMENT NOT NULL,
24
                title VARCHAR(255) NOT NULL,
25
                slug VARCHAR(255) NOT NULL,
26
                description LONGTEXT DEFAULT NULL,
27
                UNIQUE INDEX UNIQ_2DEDCC6F989D9B62 (slug),
28
                PRIMARY KEY(id)
29
            ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC
30
        ');
31
32
        $this->addSql('
33
            CREATE TABLE IF NOT EXISTS permission_rel_role (
34
                id INT AUTO_INCREMENT NOT NULL,
35
                permission_id INT NOT NULL,
36
                role_code VARCHAR(50) NOT NULL,
37
                changeable TINYINT(1) NOT NULL,
38
                updated_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime)\',
39
                INDEX IDX_43723A27FED90CCA (permission_id),
40
                PRIMARY KEY(id),
41
                CONSTRAINT FK_43723A27FED90CCA FOREIGN KEY (permission_id) REFERENCES permission (id)
42
            ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC
43
        ');
44
    }
45
46
    public function down(Schema $schema): void
47
    {
48
        $this->addSql('DROP TABLE IF EXISTS permission_rel_role');
49
        $this->addSql('DROP TABLE IF EXISTS permission');
50
    }
51
}
52