1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Chamilo\CoreBundle\Migrations\Schema\V200; |
6
|
|
|
|
7
|
|
|
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo; |
8
|
|
|
use Doctrine\DBAL\Schema\Schema; |
9
|
|
|
|
10
|
|
|
final class Version20230216122950 extends AbstractMigrationChamilo |
11
|
|
|
{ |
12
|
|
|
public function getDescription(): string |
13
|
|
|
{ |
14
|
|
|
return 'Alter tables required in configuration'; |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
public function up(Schema $schema): void |
18
|
|
|
{ |
19
|
|
|
if ($schema->hasTable('ticket_ticket')) { |
20
|
|
|
$table = $schema->getTable('ticket_ticket'); |
21
|
|
|
if (!$table->hasColumn('exercise_id')) { |
22
|
|
|
$this->addSql( |
23
|
|
|
'ALTER TABLE ticket_ticket ADD exercise_id INT DEFAULT NULL' |
24
|
|
|
); |
25
|
|
|
} |
26
|
|
|
if (!$table->hasColumn('lp_id')) { |
27
|
|
|
$this->addSql( |
28
|
|
|
'ALTER TABLE ticket_ticket ADD lp_id INT DEFAULT NULL' |
29
|
|
|
); |
30
|
|
|
} |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
if ($schema->hasTable('c_quiz_question_rel_category')) { |
34
|
|
|
$table = $schema->getTable('c_quiz_question_rel_category'); |
35
|
|
|
if (!$table->hasColumn('mandatory')) { |
36
|
|
|
$this->addSql( |
37
|
|
|
'ALTER TABLE c_quiz_question_rel_category ADD COLUMN mandatory INT DEFAULT 0' |
38
|
|
|
); |
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
if (!$schema->hasTable('c_plagiarism_compilatio_docs')) { |
43
|
|
|
$this->addSql( |
44
|
|
|
'CREATE TABLE c_plagiarism_compilatio_docs (id INT AUTO_INCREMENT NOT NULL, c_id INT NOT NULL, document_id INT NOT NULL, compilatio_id VARCHAR(32) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' |
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
if (!$schema->hasTable('notification_event')) { |
49
|
|
|
$this->addSql( |
50
|
|
|
'CREATE TABLE notification_event (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, content LONGTEXT DEFAULT NULL, link LONGTEXT DEFAULT NULL, persistent INT DEFAULT NULL, day_diff INT DEFAULT NULL, event_type VARCHAR(255) NOT NULL, event_id INT DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' |
51
|
|
|
); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
if ($schema->hasTable('system_template')) { |
55
|
|
|
$table = $schema->getTable('system_template'); |
56
|
|
|
if (!$table->hasColumn('language')) { |
57
|
|
|
$this->addSql( |
58
|
|
|
'ALTER TABLE system_template ADD language VARCHAR(40) NOT NULL DEFAULT "english"' |
59
|
|
|
); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
if (!$schema->hasTable('agenda_reminder')) { |
64
|
|
|
$this->addSql( |
65
|
|
|
'CREATE TABLE agenda_reminder (id BIGINT AUTO_INCREMENT NOT NULL, type VARCHAR(255) NOT NULL, event_id INT NOT NULL, date_interval VARCHAR(255) NOT NULL COMMENT "(DC2Type:dateinterval)", sent TINYINT(1) NOT NULL, created_at DATETIME NOT NULL COMMENT "(DC2Type:datetime)", updated_at DATETIME NOT NULL COMMENT "(DC2Type:datetime)", PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC;' |
66
|
|
|
); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
if (!$schema->hasTable('notification_event_rel_user')) { |
70
|
|
|
$this->addSql('CREATE TABLE notification_event_rel_user ( |
71
|
|
|
id INT UNSIGNED AUTO_INCREMENT NOT NULL, |
72
|
|
|
event_id INT UNSIGNED, |
73
|
|
|
user_id INT, |
74
|
|
|
PRIMARY KEY (id) |
75
|
|
|
)'); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
if (!$schema->hasTable('message_feedback')) { |
79
|
|
|
$this->addSql( |
80
|
|
|
'CREATE TABLE message_feedback (id BIGINT AUTO_INCREMENT NOT NULL, message_id BIGINT NOT NULL, user_id INT NOT NULL, liked TINYINT(1) DEFAULT 0 NOT NULL, disliked TINYINT(1) DEFAULT 0 NOT NULL, updated_at DATETIME NOT NULL COMMENT "(DC2Type:datetime)", INDEX IDX_DB0F8049537A1329 (message_id), INDEX IDX_DB0F8049A76ED395 (user_id), INDEX idx_message_feedback_uid_mid (message_id, user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' |
81
|
|
|
); |
82
|
|
|
$this->addSql( |
83
|
|
|
'ALTER TABLE message_feedback ADD CONSTRAINT FK_DB0F8049537A1329 FOREIGN KEY (message_id) REFERENCES message (id) ON DELETE CASCADE' |
84
|
|
|
); |
85
|
|
|
$this->addSql( |
86
|
|
|
'ALTER TABLE message_feedback ADD CONSTRAINT FK_DB0F8049A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE' |
87
|
|
|
); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
if (!$schema->hasTable('portfolio_attachment')) { |
91
|
|
|
$this->addSql( |
92
|
|
|
'CREATE TABLE portfolio_attachment (id INT AUTO_INCREMENT NOT NULL, path VARCHAR(255) NOT NULL, comment LONGTEXT DEFAULT NULL, size INT NOT NULL, filename VARCHAR(255) NOT NULL, origin_id INT NOT NULL, origin_type INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' |
93
|
|
|
); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
if (!$schema->hasTable('portfolio_comment')) { |
97
|
|
|
$this->addSql( |
98
|
|
|
'CREATE TABLE portfolio_comment (id INT AUTO_INCREMENT NOT NULL, author_id INT NOT NULL, item_id INT NOT NULL, tree_root INT DEFAULT NULL, parent_id INT DEFAULT NULL, visibility SMALLINT DEFAULT 1 NOT NULL, content LONGTEXT NOT NULL, date DATETIME NOT NULL COMMENT "(DC2Type:datetime)", is_important TINYINT(1) DEFAULT 0 NOT NULL, lft INT NOT NULL, lvl INT NOT NULL, rgt INT NOT NULL, score DOUBLE PRECISION DEFAULT NULL, is_template TINYINT(1) DEFAULT 0 NOT NULL, INDEX IDX_C2C17DA2F675F31B (author_id), INDEX IDX_C2C17DA2126F525E (item_id), INDEX IDX_C2C17DA2A977936C (tree_root), INDEX IDX_C2C17DA2727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' |
99
|
|
|
); |
100
|
|
|
$this->addSql( |
101
|
|
|
'ALTER TABLE portfolio_comment ADD CONSTRAINT FK_C2C17DA2F675F31B FOREIGN KEY (author_id) REFERENCES user (id) ON DELETE CASCADE' |
102
|
|
|
); |
103
|
|
|
$this->addSql( |
104
|
|
|
'ALTER TABLE portfolio_comment ADD CONSTRAINT FK_C2C17DA2126F525E FOREIGN KEY (item_id) REFERENCES portfolio (id) ON DELETE CASCADE' |
105
|
|
|
); |
106
|
|
|
$this->addSql( |
107
|
|
|
'ALTER TABLE portfolio_comment ADD CONSTRAINT FK_C2C17DA2A977936C FOREIGN KEY (tree_root) REFERENCES portfolio_comment (id) ON DELETE CASCADE' |
108
|
|
|
); |
109
|
|
|
$this->addSql( |
110
|
|
|
'ALTER TABLE portfolio_comment ADD CONSTRAINT FK_C2C17DA2727ACA70 FOREIGN KEY (parent_id) REFERENCES portfolio_comment (id) ON DELETE CASCADE' |
111
|
|
|
); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
if ($schema->hasTable('portfolio')) { |
115
|
|
|
$this->addSql( |
116
|
|
|
'ALTER TABLE portfolio ADD origin INT DEFAULT NULL, ADD origin_type INT DEFAULT NULL, ADD score DOUBLE PRECISION DEFAULT NULL, ADD is_highlighted TINYINT(1) DEFAULT 0 NOT NULL, ADD is_template TINYINT(1) DEFAULT 0 NOT NULL' |
117
|
|
|
); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
if (!$schema->hasTable('c_attendance_result_comment')) { |
121
|
|
|
$this->addSql( |
122
|
|
|
'CREATE TABLE c_attendance_result_comment (iid INT AUTO_INCREMENT NOT NULL, attendance_sheet_id INT NOT NULL, user_id INT NOT NULL, comment LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL COMMENT "(DC2Type:datetime)", updated_at DATETIME NOT NULL COMMENT "(DC2Type:datetime)", author_user_id INT NOT NULL, INDEX attendance_sheet_id (attendance_sheet_id), INDEX user_id (user_id), PRIMARY KEY(iid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' |
123
|
|
|
); |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
public function down(Schema $schema): void |
128
|
|
|
{ |
129
|
|
|
$table = $schema->getTable('gradebook_category'); |
130
|
|
|
if ($table->hasColumn('allow_skills_by_subcategory')) { |
131
|
|
|
$this->addSql('ALTER TABLE c_attendance_sheet DROP allow_skills_by_subcategory'); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
if ($schema->hasTable('c_attendance_result_comment')) { |
135
|
|
|
$this->addSql( |
136
|
|
|
'DROP TABLE c_attendance_result_comment' |
137
|
|
|
); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
$table = $schema->getTable('portfolio'); |
141
|
|
|
if ($table->hasColumn('origin')) { |
142
|
|
|
$this->addSql('ALTER TABLE portfolio DROP origin'); |
143
|
|
|
} |
144
|
|
|
if ($table->hasColumn('origin_type')) { |
145
|
|
|
$this->addSql('ALTER TABLE portfolio DROP origin_type'); |
146
|
|
|
} |
147
|
|
|
if ($table->hasColumn('score')) { |
148
|
|
|
$this->addSql('ALTER TABLE portfolio DROP score'); |
149
|
|
|
} |
150
|
|
|
if ($table->hasColumn('is_highlighted')) { |
151
|
|
|
$this->addSql('ALTER TABLE portfolio DROP is_highlighted'); |
152
|
|
|
} |
153
|
|
|
if ($table->hasColumn('is_template')) { |
154
|
|
|
$this->addSql('ALTER TABLE portfolio DROP is_template'); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
if ($schema->hasTable('portfolio_attachment')) { |
158
|
|
|
$this->addSql( |
159
|
|
|
'DROP TABLE portfolio_attachment' |
160
|
|
|
); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
if ($schema->hasTable('portfolio_comment')) { |
164
|
|
|
$this->addSql( |
165
|
|
|
'DROP TABLE portfolio_comment' |
166
|
|
|
); |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
if ($schema->hasTable('message_feedback')) { |
170
|
|
|
$this->addSql( |
171
|
|
|
'DROP TABLE message_feedback' |
172
|
|
|
); |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
if ($schema->hasTable('notification_event_rel_user')) { |
176
|
|
|
$this->addSql( |
177
|
|
|
'DROP TABLE notification_event_rel_user' |
178
|
|
|
); |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
$table = $schema->getTable('system_template'); |
182
|
|
|
if ($table->hasColumn('language')) { |
183
|
|
|
$this->addSql('ALTER TABLE system_template DROP language'); |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
if ($schema->hasTable('notification_event')) { |
187
|
|
|
$this->addSql( |
188
|
|
|
'DROP TABLE notification_event' |
189
|
|
|
); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
if ($schema->hasTable('c_plagiarism_compilatio_docs')) { |
193
|
|
|
$this->addSql( |
194
|
|
|
'DROP TABLE c_plagiarism_compilatio_docs' |
195
|
|
|
); |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
$table = $schema->getTable('ticket_ticket'); |
199
|
|
|
if ($table->hasColumn('exercise_id')) { |
200
|
|
|
$this->addSql('ALTER TABLE ticket_ticket DROP exercise_id'); |
201
|
|
|
} |
202
|
|
|
if ($table->hasColumn('lp_id')) { |
203
|
|
|
$this->addSql('ALTER TABLE ticket_ticket DROP lp_id'); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
$table = $schema->getTable('c_quiz_question_rel_category'); |
207
|
|
|
if ($table->hasColumn('mandatory')) { |
208
|
|
|
$this->addSql('ALTER TABLE c_quiz_question_rel_category DROP mandatory'); |
209
|
|
|
} |
210
|
|
|
} |
211
|
|
|
} |
212
|
|
|
|