Passed
Pull Request — master (#5720)
by
unknown
07:05
created

Version20240811221980   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 25
c 1
b 0
f 0
dl 0
loc 53
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 1 1
A up() 0 43 1
A getDescription() 0 3 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 Version20240811221980 extends AbstractMigrationChamilo
13
{
14
    public function getDescription(): string
15
    {
16
        return 'Migration to apply schema changes for notification_event_rel_user, justification_document_rel_users, and lti_external_tool tables.';
17
    }
18
19
    public function up(Schema $schema): void
20
    {
21
        $this->addSql('ALTER TABLE notification_event_rel_user DROP FOREIGN KEY IF EXISTS FK_9F7995A671F7E88B;');
22
        $this->addSql('ALTER TABLE notification_event_rel_user DROP FOREIGN KEY IF EXISTS FK_9F7995A6A76ED395;');
23
24
        $this->addSql('DROP TABLE IF EXISTS notification_event_rel_user;');
25
26
        $this->addSql('ALTER TABLE notification_event MODIFY id INT(11) NOT NULL AUTO_INCREMENT;');
27
28
        $this->addSql('
29
            CREATE TABLE notification_event_rel_user (
30
                id INT AUTO_INCREMENT NOT NULL,
31
                event_id INT NOT NULL,
32
                user_id INT NOT NULL,
33
                INDEX IDX_9F7995A671F7E88B (event_id),
34
                INDEX IDX_9F7995A6A76ED395 (user_id),
35
                PRIMARY KEY(id),
36
                CONSTRAINT FK_9F7995A671F7E88B FOREIGN KEY (event_id) REFERENCES notification_event (id) ON DELETE CASCADE,
37
                CONSTRAINT FK_9F7995A6A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE
38
            ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC;
39
        ');
40
41
        $this->addSql('ALTER TABLE notification_event_rel_user DROP FOREIGN KEY IF EXISTS FK_9F7995A671F7E88B;');
42
        $this->addSql('ALTER TABLE notification_event_rel_user DROP FOREIGN KEY IF EXISTS FK_9F7995A6A76ED395;');
43
44
        $this->addSql('ALTER TABLE notification_event_rel_user ADD CONSTRAINT FK_9F7995A671F7E88B FOREIGN KEY (event_id) REFERENCES notification_event (id);');
45
        $this->addSql('ALTER TABLE notification_event_rel_user ADD CONSTRAINT FK_9F7995A6A76ED395 FOREIGN KEY (user_id) REFERENCES user (id);');
46
47
        $this->addSql('ALTER TABLE justification_document_rel_users CHANGE justification_document_id justification_document_id INT DEFAULT NULL;');
48
49
        $this->addSql('ALTER TABLE lti_external_tool DROP INDEX IF EXISTS FK_DB0E04E41BAD783F, ADD UNIQUE INDEX UNIQ_DB0E04E41BAD783F (resource_node_id);');
50
        $this->addSql('ALTER TABLE lti_external_tool DROP FOREIGN KEY IF EXISTS FK_DB0E04E482F80D8B;');
51
        $this->addSql('ALTER TABLE lti_external_tool DROP FOREIGN KEY IF EXISTS FK_DB0E04E491D79BD3;');
52
        $this->addSql('ALTER TABLE lti_external_tool DROP FOREIGN KEY IF EXISTS FK_DB0E04E4727ACA70;');
53
        $this->addSql('DROP INDEX IF EXISTS fk_db0e04e491d79bd3 ON lti_external_tool;');
54
        $this->addSql('CREATE INDEX IDX_DB0E04E491D79BD3 ON lti_external_tool (c_id);');
55
        $this->addSql('DROP INDEX IF EXISTS fk_db0e04e482f80d8b ON lti_external_tool;');
56
        $this->addSql('CREATE INDEX IDX_DB0E04E482F80D8B ON lti_external_tool (gradebook_eval_id);');
57
        $this->addSql('DROP INDEX IF EXISTS fk_db0e04e4727aca70 ON lti_external_tool;');
58
        $this->addSql('CREATE INDEX IDX_DB0E04E4727ACA70 ON lti_external_tool (parent_id);');
59
        $this->addSql('ALTER TABLE lti_external_tool ADD CONSTRAINT FK_DB0E04E482F80D8B FOREIGN KEY (gradebook_eval_id) REFERENCES gradebook_evaluation (id) ON DELETE SET NULL;');
60
        $this->addSql('ALTER TABLE lti_external_tool ADD CONSTRAINT FK_DB0E04E491D79BD3 FOREIGN KEY (c_id) REFERENCES course (id);');
61
        $this->addSql('ALTER TABLE lti_external_tool ADD CONSTRAINT FK_DB0E04E4727ACA70 FOREIGN KEY (parent_id) REFERENCES lti_external_tool (id);');
62
    }
63
64
    public function down(Schema $schema): void {}
65
}
66