Passed
Push — master ( ab20b0...4728a8 )
by Julito
09:22
created

Version20181126174500::getDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
6
7
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
8
use Doctrine\DBAL\Schema\Schema;
9
10
class Version20181126174500 extends AbstractMigrationChamilo
11
{
12
    public function getDescription(): string
13
    {
14
        return 'Migrate plugin_ims_lti_tool';
15
    }
16
17
    public function up(Schema $schema): void
18
    {
19
        if ($schema->hasTable('plugin_ims_lti_tool')) {
20
            $schema->renameTable('plugin_ims_lti_tool', 'lti_external_tool');
21
22
            return;
23
        }
24
25
        if (false === $schema->hasTable('lti_external_tool')) {
26
            $this->addSql(
27
                'CREATE TABLE lti_external_tool (
28
                id INT AUTO_INCREMENT NOT NULL,
29
                c_id INT DEFAULT NULL,
30
                gradebook_eval_id INT DEFAULT NULL,
31
                parent_id INT DEFAULT NULL,
32
                name VARCHAR(255) NOT NULL,
33
                description LONGTEXT DEFAULT NULL,
34
                launch_url VARCHAR(255) NOT NULL,
35
                consumer_key VARCHAR(255) DEFAULT NULL,
36
                shared_secret VARCHAR(255) DEFAULT NULL,
37
                custom_params LONGTEXT DEFAULT NULL,
38
                active_deep_linking TINYINT(1) DEFAULT \'0\' NOT NULL,
39
                privacy LONGTEXT DEFAULT NULL,
40
                INDEX IDX_DB0E04E491D79BD3 (c_id),
41
                INDEX IDX_DB0E04E482F80D8B (gradebook_eval_id),
42
                INDEX IDX_DB0E04E4727ACA70 (parent_id),
43
                PRIMARY KEY(id)
44
            ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB ROW_FORMAT = DYNAMIC'
45
            );
46
            $this->addSql(
47
                'ALTER TABLE lti_external_tool ADD CONSTRAINT FK_DB0E04E491D79BD3 FOREIGN KEY (c_id) REFERENCES course (id)'
48
            );
49
            $this->addSql(
50
                'ALTER TABLE lti_external_tool ADD CONSTRAINT FK_DB0E04E482F80D8B FOREIGN KEY (gradebook_eval_id) REFERENCES gradebook_evaluation (id) ON DELETE SET NULL;'
51
            );
52
            $this->addSql(
53
                'ALTER TABLE lti_external_tool ADD CONSTRAINT FK_DB0E04E4727ACA70 FOREIGN KEY (parent_id) REFERENCES lti_external_tool (id);'
54
            );
55
        }
56
    }
57
58
    public function down(Schema $schema): void
59
    {
60
    }
61
}
62