|
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
|
|
|
if ($schema->hasTable('notification_event_rel_user')) { |
|
22
|
|
|
$this->addSql('ALTER TABLE notification_event_rel_user DROP FOREIGN KEY IF EXISTS FK_9F7995A671F7E88B;'); |
|
23
|
|
|
$this->addSql('ALTER TABLE notification_event_rel_user DROP FOREIGN KEY IF EXISTS FK_9F7995A6A76ED395;'); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
$this->addSql('DROP TABLE IF EXISTS notification_event_rel_user;'); |
|
27
|
|
|
|
|
28
|
|
|
$this->addSql('ALTER TABLE notification_event MODIFY id INT(11) NOT NULL AUTO_INCREMENT;'); |
|
29
|
|
|
|
|
30
|
|
|
$this->addSql(' |
|
31
|
|
|
CREATE TABLE notification_event_rel_user ( |
|
32
|
|
|
id INT AUTO_INCREMENT NOT NULL, |
|
33
|
|
|
event_id INT NOT NULL, |
|
34
|
|
|
user_id INT NOT NULL, |
|
35
|
|
|
INDEX IDX_9F7995A671F7E88B (event_id), |
|
36
|
|
|
INDEX IDX_9F7995A6A76ED395 (user_id), |
|
37
|
|
|
PRIMARY KEY(id), |
|
38
|
|
|
CONSTRAINT FK_9F7995A671F7E88B FOREIGN KEY (event_id) REFERENCES notification_event (id) ON DELETE CASCADE, |
|
39
|
|
|
CONSTRAINT FK_9F7995A6A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE |
|
40
|
|
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC; |
|
41
|
|
|
'); |
|
42
|
|
|
|
|
43
|
|
|
$this->addSql('ALTER TABLE notification_event_rel_user DROP FOREIGN KEY IF EXISTS FK_9F7995A671F7E88B;'); |
|
44
|
|
|
$this->addSql('ALTER TABLE notification_event_rel_user DROP FOREIGN KEY IF EXISTS FK_9F7995A6A76ED395;'); |
|
45
|
|
|
|
|
46
|
|
|
$this->addSql('ALTER TABLE notification_event_rel_user ADD CONSTRAINT FK_9F7995A671F7E88B FOREIGN KEY (event_id) REFERENCES notification_event (id);'); |
|
47
|
|
|
$this->addSql('ALTER TABLE notification_event_rel_user ADD CONSTRAINT FK_9F7995A6A76ED395 FOREIGN KEY (user_id) REFERENCES user (id);'); |
|
48
|
|
|
|
|
49
|
|
|
if ($schema->hasTable('justification_document_rel_users')) { |
|
50
|
|
|
$this->addSql('ALTER TABLE justification_document_rel_users CHANGE justification_document_id justification_document_id INT DEFAULT NULL;'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
$this->addSql('ALTER TABLE lti_external_tool DROP FOREIGN KEY IF EXISTS FK_DB0E04E41BAD783F;'); |
|
54
|
|
|
$this->addSql('ALTER TABLE lti_external_tool DROP INDEX IF EXISTS FK_DB0E04E41BAD783F;'); |
|
55
|
|
|
$table = $schema->getTable('lti_external_tool'); |
|
56
|
|
|
if (false === $table->hasIndex('UNIQ_DB0E04E41BAD783F')) { |
|
57
|
|
|
$this->addSql('ALTER TABLE lti_external_tool ADD UNIQUE INDEX UNIQ_DB0E04E41BAD783F (resource_node_id);'); |
|
58
|
|
|
} |
|
59
|
|
|
$this->addSql('ALTER TABLE lti_external_tool DROP FOREIGN KEY IF EXISTS FK_DB0E04E482F80D8B;'); |
|
60
|
|
|
$this->addSql('ALTER TABLE lti_external_tool DROP FOREIGN KEY IF EXISTS FK_DB0E04E491D79BD3;'); |
|
61
|
|
|
$this->addSql('ALTER TABLE lti_external_tool DROP FOREIGN KEY IF EXISTS FK_DB0E04E4727ACA70;'); |
|
62
|
|
|
$this->addSql('DROP INDEX IF EXISTS fk_db0e04e491d79bd3 ON lti_external_tool;'); |
|
63
|
|
|
if (false === $table->hasIndex('IDX_DB0E04E491D79BD3')) { |
|
64
|
|
|
$this->addSql('CREATE INDEX IDX_DB0E04E491D79BD3 ON lti_external_tool (c_id);'); |
|
65
|
|
|
} |
|
66
|
|
|
$this->addSql('DROP INDEX IF EXISTS fk_db0e04e482f80d8b ON lti_external_tool;'); |
|
67
|
|
|
if (false === $table->hasIndex('IDX_DB0E04E482F80D8B')) { |
|
68
|
|
|
$this->addSql('CREATE INDEX IDX_DB0E04E482F80D8B ON lti_external_tool (gradebook_eval_id);'); |
|
69
|
|
|
} |
|
70
|
|
|
$this->addSql('DROP INDEX IF EXISTS fk_db0e04e4727aca70 ON lti_external_tool;'); |
|
71
|
|
|
if (false === $table->hasIndex('IDX_DB0E04E4727ACA70')) { |
|
72
|
|
|
$this->addSql('CREATE INDEX IDX_DB0E04E4727ACA70 ON lti_external_tool (parent_id);'); |
|
73
|
|
|
} |
|
74
|
|
|
if (!$table->hasForeignKey('FK_DB0E04E482F80D8B')) { |
|
75
|
|
|
$this->addSql('ALTER TABLE lti_external_tool ADD CONSTRAINT FK_DB0E04E482F80D8B FOREIGN KEY (gradebook_eval_id) REFERENCES gradebook_evaluation (id) ON DELETE SET NULL;'); |
|
76
|
|
|
} |
|
77
|
|
|
if (!$table->hasForeignKey('FK_DB0E04E491D79BD3')) { |
|
78
|
|
|
$this->addSql('ALTER TABLE lti_external_tool ADD CONSTRAINT FK_DB0E04E491D79BD3 FOREIGN KEY (c_id) REFERENCES course (id);'); |
|
79
|
|
|
} |
|
80
|
|
|
if (!$table->hasForeignKey('FK_DB0E04E4727ACA70')) { |
|
81
|
|
|
$this->addSql('ALTER TABLE lti_external_tool ADD CONSTRAINT FK_DB0E04E4727ACA70 FOREIGN KEY (parent_id) REFERENCES lti_external_tool (id);'); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
public function down(Schema $schema): void {} |
|
86
|
|
|
} |
|
87
|
|
|
|