|
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
|
|
|
class Version20251002110001 extends AbstractMigrationChamilo |
|
13
|
|
|
{ |
|
14
|
|
|
public function getDescription(): string |
|
15
|
|
|
{ |
|
16
|
|
|
return "Check and add columns on LTI tables"; |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @inheritDoc |
|
21
|
|
|
*/ |
|
22
|
|
|
public function up(Schema $schema): void |
|
23
|
|
|
{ |
|
24
|
|
|
$lineItem = $schema->getTable('lti_lineitem'); |
|
25
|
|
|
|
|
26
|
|
|
if ($lineItem->hasIndex('IDX_5C76B75D8F7B22CC')) { |
|
27
|
|
|
$this->addSql("DROP INDEX IDX_5C76B75D8F7B22CC ON lti_lineitem"); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
if ($lineItem->hasForeignKey('FK_5C76B75D8F7B22CC')) { |
|
31
|
|
|
$this->addSql("ALTER TABLE lti_lineitem DROP FOREIGN KEY FK_5C76B75D8F7B22CC"); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
if ($lineItem->hasColumn('tool_id')) { |
|
35
|
|
|
$this->addSql('ALTER TABLE lti_lineitem DROP COLUMN tool_id'); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
$this->addSql("ALTER TABLE lti_lineitem ADD tool_id INT NOT NULL"); |
|
39
|
|
|
$this->addSql("ALTER TABLE lti_lineitem ADD CONSTRAINT FK_5C76B75D8F7B22CC FOREIGN KEY (tool_id) REFERENCES lti_external_tool (id) ON DELETE CASCADE"); |
|
40
|
|
|
$this->addSql("CREATE INDEX IDX_5C76B75D8F7B22CC ON lti_lineitem (tool_id)"); |
|
41
|
|
|
|
|
42
|
|
|
if ($lineItem->hasIndex('UNIQ_5C76B75D1323A575')) { |
|
43
|
|
|
$this->addSql("DROP INDEX UNIQ_5C76B75D1323A575 ON lti_lineitem"); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
if ($lineItem->hasForeignKey('FK_5C76B75D1323A575')) { |
|
47
|
|
|
$this->addSql("ALTER TABLE lti_lineitem DROP FOREIGN KEY FK_5C76B75D1323A575"); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
if ($lineItem->hasColumn('evaluation')) { |
|
51
|
|
|
$this->addSql("ALTER TABLE lti_lineitem DROP COLUMN evaluation"); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
$this->addSql("ALTER TABLE lti_lineitem ADD evaluation INT NOT NULL"); |
|
55
|
|
|
$this->addSql("ALTER TABLE lti_lineitem ADD CONSTRAINT FK_5C76B75D1323A575 FOREIGN KEY (evaluation) REFERENCES gradebook_evaluation (id) ON DELETE CASCADE"); |
|
56
|
|
|
$this->addSql("CREATE UNIQUE INDEX UNIQ_5C76B75D1323A575 ON lti_lineitem (evaluation)"); |
|
57
|
|
|
|
|
58
|
|
|
if ($lineItem->hasColumn('resource_id')) { |
|
59
|
|
|
$this->addSql("ALTER TABLE DROP COLUMN resource_id"); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
$this->addSql("ALTER TABLE lti_lineitem ADD resource_id VARCHAR(255) DEFAULT NULL"); |
|
63
|
|
|
|
|
64
|
|
|
if ($lineItem->hasColumn('tag')) { |
|
65
|
|
|
$this->addSql("ALTER TABLE DROP COLUMN tag"); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
$this->addSql("ALTER TABLE lti_lineitem ADD tag VARCHAR(255) DEFAULT NULL"); |
|
69
|
|
|
|
|
70
|
|
|
if ($lineItem->hasColumn('start_date')) { |
|
71
|
|
|
$this->addSql("ALTER TABLE DROP COLUMN start_date"); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
$this->addSql("ALTER TABLE lti_lineitem ADD start_date DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime)'"); |
|
75
|
|
|
|
|
76
|
|
|
if ($lineItem->hasColumn('end_date')) { |
|
77
|
|
|
$this->addSql("ALTER TABLE DROP COLUMN end_date"); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
$this->addSql("ALTER TABLE lti_lineitem ADD end_date DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime)'"); |
|
81
|
|
|
|
|
82
|
|
|
$externalTool = $schema->getTable('lti_external_tool'); |
|
83
|
|
|
|
|
84
|
|
|
if ($externalTool->hasIndex('UNIQ_DB0E04E41BAD783F')) { |
|
85
|
|
|
$this->addSql("DROP INDEX UNIQ_DB0E04E41BAD783F ON lti_external_tool"); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
if ($externalTool->hasForeignKey('FK_DB0E04E41BAD783F')) { |
|
89
|
|
|
$this->addSql("ALTER TABLE lti_external_tool DROP FOREIGN KEY FK_DB0E04E41BAD783F"); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
if ($externalTool->hasColumn('resource_node_id')) { |
|
93
|
|
|
$this->addSql("ALTER TABLE lti_external_tool DROP COLUMN resource_node_id"); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
$this->addSql("ALTER TABLE lti_external_tool ADD resource_node_id INT DEFAULT NULL"); |
|
97
|
|
|
$this->addSql('ALTER TABLE lti_external_tool ADD CONSTRAINT FK_DB0E04E41BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE'); |
|
98
|
|
|
$this->addSql("CREATE UNIQUE INDEX UNIQ_DB0E04E41BAD783F ON lti_external_tool (resource_node_id)"); |
|
99
|
|
|
|
|
100
|
|
|
if ($externalTool->hasIndex('IDX_DB0E04E482F80D8B')) { |
|
101
|
|
|
$this->addSql("DROP INDEX IDX_DB0E04E482F80D8B ON lti_external_tool"); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
if ($externalTool->hasForeignKey('FK_DB0E04E482F80D8B')) { |
|
105
|
|
|
$this->addSql("ALTER TABLE lti_external_tool DROP FOREIGN KEY FK_DB0E04E482F80D8B"); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
if ($externalTool->hasColumn('gradebook_eval_id')) { |
|
109
|
|
|
$this->addSql("ALTER TABLE lti_external_tool DROP COLUMN gradebook_eval_id"); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
$this->addSql("ALTER TABLE lti_external_tool ADD gradebook_eval_id INT DEFAULT NULL"); |
|
113
|
|
|
$this->addSql("ALTER TABLE lti_external_tool ADD CONSTRAINT FK_DB0E04E482F80D8B FOREIGN KEY (gradebook_eval_id) REFERENCES gradebook_evaluation (id) ON DELETE SET NULL"); |
|
114
|
|
|
$this->addSql("CREATE INDEX IDX_DB0E04E482F80D8B ON lti_external_tool (gradebook_eval_id)"); |
|
115
|
|
|
|
|
116
|
|
|
if ($externalTool->hasColumn('title')) { |
|
117
|
|
|
$this->addSql("ALTER TABLE lti_external_tool DROP COLUMN title"); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
$this->addSql("ALTER TABLE lti_external_tool ADD title VARCHAR(255) NOT NULL"); |
|
121
|
|
|
|
|
122
|
|
|
if ($externalTool->hasColumn('description')) { |
|
123
|
|
|
$this->addSql("ALTER TABLE lti_external_tool DROP COLUMN description"); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
$this->addSql("ALTER TABLE lti_external_tool ADD description LONGTEXT DEFAULT NULL"); |
|
127
|
|
|
|
|
128
|
|
|
if ($externalTool->hasColumn('public_key')) { |
|
129
|
|
|
$this->addSql("ALTER TABLE lti_external_tool DROP COLUMN public_key"); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
$this->addSql("ALTER TABLE lti_external_tool ADD public_key LONGTEXT DEFAULT NULL"); |
|
133
|
|
|
|
|
134
|
|
|
if ($externalTool->hasColumn('launch_url')) { |
|
135
|
|
|
$this->addSql("ALTER TABLE lti_external_tool DROP COLUMN launch_url"); |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
$this->addSql("ALTER TABLE lti_external_tool ADD launch_url VARCHAR(255) NOT NULL"); |
|
139
|
|
|
|
|
140
|
|
|
if ($externalTool->hasColumn('consumer_key')) { |
|
141
|
|
|
$this->addSql("ALTER TABLE lti_external_tool DROP COLUMN consumer_key"); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
$this->addSql("ALTER TABLE lti_external_tool ADD consumer_key VARCHAR(255) DEFAULT NULL"); |
|
145
|
|
|
|
|
146
|
|
|
if ($externalTool->hasColumn('shared_secret')) { |
|
147
|
|
|
$this->addSql("ALTER TABLE lti_external_tool DROP COLUMN shared_secret"); |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
$this->addSql("ALTER TABLE lti_external_tool ADD shared_secret VARCHAR(255) DEFAULT NULL"); |
|
151
|
|
|
|
|
152
|
|
|
if ($externalTool->hasColumn('custom_params')) { |
|
153
|
|
|
$this->addSql("ALTER TABLE lti_external_tool DROP COLUMN custom_params"); |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
$this->addSql("ALTER TABLE lti_external_tool ADD custom_params LONGTEXT DEFAULT NULL"); |
|
157
|
|
|
|
|
158
|
|
|
if ($externalTool->hasColumn('active_deep_linking')) { |
|
159
|
|
|
$this->addSql("ALTER TABLE lti_external_tool DROP COLUMN active_deep_linking"); |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
$this->addSql("ALTER TABLE lti_external_tool ADD active_deep_linking TINYINT(1) DEFAULT 0 NOT NULL"); |
|
163
|
|
|
|
|
164
|
|
|
if ($externalTool->hasColumn('privacy')) { |
|
165
|
|
|
$this->addSql("ALTER TABLE lti_external_tool DROP COLUMN privacy"); |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
$this->addSql("ALTER TABLE lti_external_tool ADD privacy LONGTEXT DEFAULT NULL"); |
|
169
|
|
|
|
|
170
|
|
|
if ($externalTool->hasColumn('client_id')) { |
|
171
|
|
|
$this->addSql("ALTER TABLE lti_external_tool DROP COLUMN client_id"); |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
$this->addSql("ALTER TABLE lti_external_tool ADD client_id VARCHAR(255) DEFAULT NULL"); |
|
175
|
|
|
|
|
176
|
|
|
if ($externalTool->hasColumn('login_url')) { |
|
177
|
|
|
$this->addSql("ALTER TABLE lti_external_tool DROP COLUMN login_url"); |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
$this->addSql("ALTER TABLE lti_external_tool ADD login_url VARCHAR(255) DEFAULT NULL"); |
|
181
|
|
|
|
|
182
|
|
|
if ($externalTool->hasColumn('redirect_url')) { |
|
183
|
|
|
$this->addSql("ALTER TABLE lti_external_tool DROP COLUMN redirect_url"); |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
$this->addSql("ALTER TABLE lti_external_tool ADD redirect_url VARCHAR(255) DEFAULT NULL"); |
|
187
|
|
|
|
|
188
|
|
|
if ($externalTool->hasColumn('jwks_url')) { |
|
189
|
|
|
$this->addSql("ALTER TABLE lti_external_tool DROP COLUMN jwks_url"); |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
$this->addSql("ALTER TABLE lti_external_tool ADD jwks_url VARCHAR(255) DEFAULT NULL"); |
|
193
|
|
|
|
|
194
|
|
|
if ($externalTool->hasColumn('advantage_services')) { |
|
195
|
|
|
$this->addSql("ALTER TABLE lti_external_tool DROP COLUMN advantage_services"); |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
$this->addSql("ALTER TABLE lti_external_tool ADD advantage_services JSON DEFAULT NULL COMMENT '(DC2Type:json)'"); |
|
199
|
|
|
|
|
200
|
|
|
if ($externalTool->hasColumn('version')) { |
|
201
|
|
|
$this->addSql("ALTER TABLE lti_external_tool DROP COLUMN version"); |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
$this->addSql("ALTER TABLE lti_external_tool ADD version VARCHAR(255) DEFAULT 'lti1p3' NOT NULL"); |
|
205
|
|
|
|
|
206
|
|
|
if ($externalTool->hasColumn('launch_presentation')) { |
|
207
|
|
|
$this->addSql("ALTER TABLE lti_external_tool DROP COLUMN launch_presentation"); |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
$this->addSql("ALTER TABLE lti_external_tool ADD launch_presentation JSON NOT NULL COMMENT '(DC2Type:json)'"); |
|
211
|
|
|
|
|
212
|
|
|
if ($externalTool->hasColumn('replacement_params')) { |
|
213
|
|
|
$this->addSql("ALTER TABLE lti_external_tool DROP COLUMN replacement_params"); |
|
214
|
|
|
} |
|
215
|
|
|
|
|
216
|
|
|
$this->addSql("ALTER TABLE lti_external_tool ADD replacement_params JSON NOT NULL COMMENT '(DC2Type:json)'"); |
|
217
|
|
|
|
|
218
|
|
|
$token = $schema->getTable('lti_token'); |
|
219
|
|
|
|
|
220
|
|
|
if ($token->hasIndex('IDX_EA71C468F7B22CC')) { |
|
221
|
|
|
$this->addSql("DROP INDEX IDX_EA71C468F7B22CC ON lti_token"); |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
if ($token->hasForeignKey('FK_EA71C468F7B22CC')) { |
|
225
|
|
|
$this->addSql("ALTER TABLE lti_token DROP FOREIGN KEY FK_EA71C468F7B22CC"); |
|
226
|
|
|
} |
|
227
|
|
|
|
|
228
|
|
|
if ($token->hasColumn('tool_id')) { |
|
229
|
|
|
$this->addSql("ALTER TABLE lti_token DROP COLUMN tool_id"); |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
$this->addSql("ALTER TABLE lti_token ADD tool_id INT DEFAULT NULL"); |
|
233
|
|
|
$this->addSql("ALTER TABLE lti_token ADD CONSTRAINT FK_EA71C468F7B22CC FOREIGN KEY (tool_id) REFERENCES lti_external_tool (id) ON DELETE CASCADE"); |
|
234
|
|
|
$this->addSql("CREATE INDEX IDX_EA71C468F7B22CC ON lti_token (tool_id)"); |
|
235
|
|
|
|
|
236
|
|
|
if ($token->hasColumn('scope')) { |
|
237
|
|
|
$this->addSql("ALTER TABLE lti_token DROP COLUMN scope"); |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
$this->addSql("ALTER TABLE lti_token ADD scope JSON NOT NULL COMMENT '(DC2Type:json)'"); |
|
241
|
|
|
|
|
242
|
|
|
if ($token->hasColumn('hash')) { |
|
243
|
|
|
$this->addSql("ALTER TABLE lti_token DROP COLUMN hash"); |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
|
|
$this->addSql("ALTER TABLE lti_token ADD hash VARCHAR(255) NOT NULL"); |
|
247
|
|
|
|
|
248
|
|
|
if ($token->hasColumn('created_at')) { |
|
249
|
|
|
$this->addSql("ALTER TABLE lti_token DROP COLUMN created_at"); |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
|
|
$this->addSql("ALTER TABLE lti_token ADD created_at INT NOT NULL"); |
|
253
|
|
|
|
|
254
|
|
|
if ($token->hasColumn('expires_at')) { |
|
255
|
|
|
$this->addSql("ALTER TABLE lti_token DROP COLUMN expires_at"); |
|
256
|
|
|
} |
|
257
|
|
|
|
|
258
|
|
|
$this->addSql("ALTER TABLE lti_token ADD expires_at INT NOT NULL"); |
|
259
|
|
|
|
|
260
|
|
|
$platform = $schema->getTable('lti_platform'); |
|
261
|
|
|
|
|
262
|
|
|
if ($token->hasColumn('public_key')) { |
|
263
|
|
|
$this->addSql("ALTER TABLE lti_platform DROP COLUMN public_key"); |
|
264
|
|
|
} |
|
265
|
|
|
|
|
266
|
|
|
$this->addSql("ALTER TABLE lti_platform ADD public_key LONGTEXT NOT NULL"); |
|
267
|
|
|
|
|
268
|
|
|
if ($token->hasColumn('kid')) { |
|
269
|
|
|
$this->addSql("ALTER TABLE lti_platform DROP COLUMN kid"); |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
$this->addSql("ALTER TABLE lti_platform ADD kid VARCHAR(255) NOT NULL"); |
|
273
|
|
|
|
|
274
|
|
|
if ($token->hasColumn('private_key')) { |
|
275
|
|
|
$this->addSql("ALTER TABLE lti_platform DROP COLUMN private_key"); |
|
276
|
|
|
} |
|
277
|
|
|
|
|
278
|
|
|
$this->addSql("ALTER TABLE lti_platform ADD private_key LONGTEXT NOT NULL"); |
|
279
|
|
|
} |
|
280
|
|
|
} |
|
281
|
|
|
|