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 Version20201211114900 extends AbstractMigrationChamilo |
13
|
|
|
{ |
14
|
|
|
public function getDescription(): string |
15
|
|
|
{ |
16
|
|
|
return 'Migrate access_url, users'; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
public function up(Schema $schema): void |
20
|
|
|
{ |
21
|
|
|
error_log('MIGRATIONS :: FILE -- Version20201211114900 ...'); |
22
|
|
|
|
23
|
|
|
if ($schema->hasTable('gradebook_category')) { |
24
|
|
|
$table = $schema->getTable('gradebook_category'); |
25
|
|
|
if (!$table->hasColumn('allow_skills_by_subcategory')) { |
26
|
|
|
$this->addSql( |
27
|
|
|
'ALTER TABLE gradebook_category ADD allow_skills_by_subcategory INT DEFAULT 1' |
28
|
|
|
); |
29
|
|
|
} |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
if ($schema->hasTable('c_survey_answer')) { |
33
|
|
|
$table = $schema->getTable('c_survey_answer'); |
34
|
|
|
if (!$table->hasColumn('session_id')) { |
35
|
|
|
$this->addSql( |
36
|
|
|
'ALTER TABLE c_survey_answer ADD session_id INT NOT NULL' |
37
|
|
|
); |
38
|
|
|
} |
39
|
|
|
if (!$table->hasColumn('c_lp_item_id')) { |
40
|
|
|
$this->addSql( |
41
|
|
|
'ALTER TABLE c_survey_answer ADD c_lp_item_id INT NOT NULL' |
42
|
|
|
); |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
if ($schema->hasTable('c_survey_invitation')) { |
47
|
|
|
$table = $schema->getTable('c_survey_invitation'); |
48
|
|
|
if (!$table->hasColumn('c_lp_item_id')) { |
49
|
|
|
$this->addSql( |
50
|
|
|
'ALTER TABLE c_survey_invitation ADD c_lp_item_id INT NOT NULL' |
51
|
|
|
); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
if ($schema->hasTable('c_quiz')) { |
56
|
|
|
$table = $schema->getTable('c_quiz'); |
57
|
|
|
if (!$table->hasColumn('hide_attempts_table')) { |
58
|
|
|
$this->addSql( |
59
|
|
|
'ALTER TABLE c_quiz ADD hide_attempts_table TINYINT(1) NOT NULL' |
60
|
|
|
); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
if ($schema->hasTable('c_attendance_calendar')) { |
65
|
|
|
$table = $schema->getTable('c_attendance_calendar'); |
66
|
|
|
if (!$table->hasColumn('blocked')) { |
67
|
|
|
$this->addSql( |
68
|
|
|
'ALTER TABLE c_attendance_calendar ADD blocked TINYINT(1) DEFAULT NULL' |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
if ($schema->hasTable('c_attendance_sheet')) { |
74
|
|
|
$table = $schema->getTable('c_attendance_sheet'); |
75
|
|
|
if (!$table->hasColumn('signature')) { |
76
|
|
|
$this->addSql( |
77
|
|
|
'ALTER TABLE c_attendance_sheet ADD signature VARCHAR(255) DEFAULT NULL' |
78
|
|
|
); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
if ($schema->hasTable('c_lp')) { |
83
|
|
|
$table = $schema->getTable('c_lp'); |
84
|
|
|
if (!$table->hasColumn('published_on')) { |
85
|
|
|
$this->addSql( |
86
|
|
|
'ALTER TABLE c_lp CHANGE publicated_on published_on datetime NULL;' |
87
|
|
|
); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
if ($schema->hasTable('c_lp')) { |
92
|
|
|
$table = $schema->getTable('c_lp'); |
93
|
|
|
if (!$table->hasColumn('next_lp_id')) { |
94
|
|
|
$this->addSql( |
95
|
|
|
'ALTER TABLE c_lp ADD next_lp_id INT DEFAULT 0 NOT NULL' |
96
|
|
|
); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
if ($schema->hasTable('c_lp_item')) { |
101
|
|
|
$table = $schema->getTable('c_lp_item'); |
102
|
|
|
if (!$table->hasColumn('item_root')) { |
103
|
|
|
$this->addSql( |
104
|
|
|
'ALTER TABLE c_lp_item CHANGE c_id item_root INT DEFAULT NULL' |
105
|
|
|
); |
106
|
|
|
$this->addSql( |
107
|
|
|
'ALTER TABLE c_lp_item ADD CONSTRAINT FK_CCC9C1EDDEC4BDA0 FOREIGN KEY (item_root) REFERENCES c_lp_item (iid) ON DELETE CASCADE' |
108
|
|
|
); |
109
|
|
|
$this->addSql( |
110
|
|
|
'CREATE INDEX IDX_CCC9C1EDDEC4BDA0 ON c_lp_item (item_root)' |
111
|
|
|
); |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
if (!$schema->hasTable('c_wiki_category')) { |
116
|
|
|
$this->addSql( |
117
|
|
|
'CREATE TABLE c_wiki_category (id INT AUTO_INCREMENT NOT NULL, c_id INT NOT NULL, session_id INT DEFAULT NULL, tree_root INT DEFAULT NULL, parent_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, lft INT NOT NULL, lvl INT NOT NULL, rgt INT NOT NULL, INDEX IDX_17F1099A91D79BD3 (c_id), INDEX IDX_17F1099A613FECDF (session_id), INDEX IDX_17F1099AA977936C (tree_root), INDEX IDX_17F1099A727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' |
118
|
|
|
); |
119
|
|
|
$this->addSql( |
120
|
|
|
'ALTER TABLE c_wiki_category ADD CONSTRAINT FK_17F1099A91D79BD3 FOREIGN KEY (c_id) REFERENCES course (id) ON DELETE CASCADE' |
121
|
|
|
); |
122
|
|
|
$this->addSql( |
123
|
|
|
'ALTER TABLE c_wiki_category ADD CONSTRAINT FK_17F1099A613FECDF FOREIGN KEY (session_id) REFERENCES session (id) ON DELETE CASCADE' |
124
|
|
|
); |
125
|
|
|
$this->addSql( |
126
|
|
|
'ALTER TABLE c_wiki_category ADD CONSTRAINT FK_17F1099AA977936C FOREIGN KEY (tree_root) REFERENCES c_wiki_category (id) ON DELETE CASCADE' |
127
|
|
|
); |
128
|
|
|
$this->addSql( |
129
|
|
|
'ALTER TABLE c_wiki_category ADD CONSTRAINT FK_17F1099A727ACA70 FOREIGN KEY (parent_id) REFERENCES c_wiki_category (id) ON DELETE CASCADE' |
130
|
|
|
); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
if (!$schema->hasTable('c_wiki_rel_category')) { |
134
|
|
|
$this->addSql( |
135
|
|
|
'CREATE TABLE c_wiki_rel_category (wiki_id INT NOT NULL, category_id INT NOT NULL, INDEX IDX_AC88945BAA948DBE (wiki_id), INDEX IDX_AC88945B12469DE2 (category_id), PRIMARY KEY(wiki_id, category_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' |
136
|
|
|
); |
137
|
|
|
$this->addSql( |
138
|
|
|
'ALTER TABLE c_wiki_rel_category ADD CONSTRAINT FK_AC88945BAA948DBE FOREIGN KEY (wiki_id) REFERENCES c_wiki (iid) ON DELETE CASCADE' |
139
|
|
|
); |
140
|
|
|
$this->addSql( |
141
|
|
|
'ALTER TABLE c_wiki_rel_category ADD CONSTRAINT FK_AC88945B12469DE2 FOREIGN KEY (category_id) REFERENCES c_wiki_category (id) ON DELETE CASCADE' |
142
|
|
|
); |
143
|
|
|
} |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
public function down(Schema $schema): void |
147
|
|
|
{ |
148
|
|
|
if ($schema->hasTable('c_wiki_category')) { |
149
|
|
|
$this->addSql( |
150
|
|
|
'DROP TABLE c_wiki_category' |
151
|
|
|
); |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
if ($schema->hasTable('c_wiki_rel_category')) { |
155
|
|
|
$this->addSql( |
156
|
|
|
'DROP TABLE c_wiki_rel_category' |
157
|
|
|
); |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
if ($schema->hasTable('c_lp_item')) { |
161
|
|
|
$table = $schema->getTable('c_lp_item'); |
162
|
|
|
if ($table->hasColumn('item_root')) { |
163
|
|
|
$this->addSql( |
164
|
|
|
'ALTER TABLE c_lp_item CHANGE item_root c_id INT DEFAULT NULL' |
165
|
|
|
); |
166
|
|
|
} |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
$table = $schema->getTable('c_lp'); |
170
|
|
|
if ($table->hasColumn('next_lp_id')) { |
171
|
|
|
$this->addSql('ALTER TABLE c_lp DROP next_lp_id'); |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
if ($schema->hasTable('c_lp')) { |
175
|
|
|
$table = $schema->getTable('c_lp'); |
176
|
|
|
if ($table->hasColumn('published_on')) { |
177
|
|
|
$this->addSql( |
178
|
|
|
'ALTER TABLE c_lp CHANGE published_on publicated_on datetime NULL;' |
179
|
|
|
); |
180
|
|
|
} |
181
|
|
|
} |
182
|
|
|
$table = $schema->getTable('c_attendance_sheet'); |
183
|
|
|
if ($table->hasColumn('signature')) { |
184
|
|
|
$this->addSql('ALTER TABLE c_attendance_sheet DROP signature'); |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
$table = $schema->getTable('c_attendance_calendar'); |
188
|
|
|
if ($table->hasColumn('blocked')) { |
189
|
|
|
$this->addSql('ALTER TABLE c_attendance_calendar DROP blocked'); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
$table = $schema->getTable('c_quiz'); |
193
|
|
|
if ($table->hasColumn('hide_attempts_table')) { |
194
|
|
|
$this->addSql('ALTER TABLE c_quiz DROP hide_attempts_table'); |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
$table = $schema->getTable('c_survey_answer'); |
198
|
|
|
if ($table->hasColumn('session_id')) { |
199
|
|
|
$this->addSql('ALTER TABLE c_survey_answer DROP session_id'); |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
if ($table->hasColumn('c_lp_item_id')) { |
203
|
|
|
$this->addSql('ALTER TABLE c_survey_answer DROP c_lp_item_id'); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
$table = $schema->getTable('c_survey_invitation'); |
207
|
|
|
if ($table->hasColumn('c_lp_item_id')) { |
208
|
|
|
$this->addSql('ALTER TABLE c_survey_invitation DROP c_lp_item_id'); |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
$table = $schema->getTable('gradebook_category'); |
212
|
|
|
if ($table->hasColumn('allow_skills_by_subcategory')) { |
213
|
|
|
$this->addSql('ALTER TABLE gradebook_category DROP allow_skills_by_subcategory'); |
214
|
|
|
} |
215
|
|
|
} |
216
|
|
|
} |
217
|
|
|
|