Passed
Push — master ( dc7998...b60aa1 )
by
unknown
11:16
created

Version20201210100002   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 5 1
A up() 0 8 1
A getDescription() 0 3 1
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
final class Version20201210100002 extends AbstractMigrationChamilo
13
{
14
    public function getDescription(): string
15
    {
16
        return 'Create the plugin table to manage plugin installation and activation.';
17
    }
18
19
    public function up(Schema $schema): void
20
    {
21
        // Create the plugin table
22
        $this->addSql("CREATE TABLE plugin (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, installed TINYINT(1) NOT NULL, installed_version VARCHAR(20) NOT NULL, source VARCHAR(20) DEFAULT 'third_party' NOT NULL, UNIQUE INDEX UNIQ_E96E27942B36786B (title), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC");
23
24
        $this->addSql("CREATE TABLE access_url_rel_plugin (id INT AUTO_INCREMENT NOT NULL, plugin_id INT NOT NULL, url_id INT NOT NULL, active TINYINT(1) NOT NULL, configuration LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', INDEX IDX_7167B425EC942BCF (plugin_id), INDEX IDX_7167B42581CFDAE7 (url_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC");
25
        $this->addSql('ALTER TABLE access_url_rel_plugin ADD CONSTRAINT FK_7167B425EC942BCF FOREIGN KEY (plugin_id) REFERENCES plugin (id)');
26
        $this->addSql('ALTER TABLE access_url_rel_plugin ADD CONSTRAINT FK_7167B42581CFDAE7 FOREIGN KEY (url_id) REFERENCES access_url (id)');
27
    }
28
29
    public function down(Schema $schema): void
30
    {
31
        // Drop the plugin table if rolling back the migration
32
        $this->addSql('DROP TABLE access_url_rel_plugin;');
33
        $this->addSql('DROP TABLE plugin;');
34
    }
35
}
36