|
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
|
|
|
/** |
|
13
|
|
|
* c_thematic. |
|
14
|
|
|
*/ |
|
15
|
|
|
class Version20170625143000 extends AbstractMigrationChamilo |
|
16
|
|
|
{ |
|
17
|
|
|
public function up(Schema $schema): void |
|
18
|
|
|
{ |
|
19
|
|
|
$table = $schema->getTable('c_thematic'); |
|
20
|
|
|
if (false === $table->hasColumn('resource_node_id')) { |
|
21
|
|
|
$this->addSql('ALTER TABLE c_thematic ADD resource_node_id INT DEFAULT NULL'); |
|
22
|
|
|
$this->addSql( |
|
23
|
|
|
'ALTER TABLE c_thematic ADD CONSTRAINT FK_6D8F59B91BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE' |
|
24
|
|
|
); |
|
25
|
|
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_6D8F59B91BAD783F ON c_thematic (resource_node_id)'); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
if ($table->hasIndex('course')) { |
|
29
|
|
|
$this->addSql('DROP INDEX course ON c_thematic'); |
|
30
|
|
|
} |
|
31
|
|
|
if ($table->hasIndex('active')) { |
|
32
|
|
|
$this->addSql('DROP INDEX active ON c_thematic'); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
if ($table->hasColumn('c_id')) { |
|
36
|
|
|
//$this->addSql('ALTER TABLE c_thematic DROP c_id'); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
if ($table->hasColumn('session_id')) { |
|
40
|
|
|
//$this->addSql('ALTER TABLE c_thematic DROP session_id'); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
if ($table->hasIndex('active')) { |
|
44
|
|
|
$this->addSql('CREATE INDEX active ON c_thematic (active);'); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
$table = $schema->getTable('c_thematic_advance'); |
|
48
|
|
|
if ($table->hasIndex('course')) { |
|
49
|
|
|
$this->addSql('DROP INDEX course ON c_thematic_advance'); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
if ($table->hasColumn('c_id')) { |
|
53
|
|
|
//$this->addSql('ALTER TABLE c_thematic_advance DROP c_id;'); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
if ($table->hasIndex('thematic_id')) { |
|
57
|
|
|
$this->addSql('DROP INDEX thematic_id ON c_thematic_advance'); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
if (false === $table->hasIndex('IDX_62798E972395FCED')) { |
|
61
|
|
|
$this->addSql('CREATE INDEX IDX_62798E972395FCED ON c_thematic_advance (thematic_id)'); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
$this->addSql( |
|
65
|
|
|
'ALTER TABLE c_thematic_advance CHANGE thematic_id thematic_id INT DEFAULT NULL, CHANGE attendance_id attendance_id INT DEFAULT NULL' |
|
66
|
|
|
); |
|
67
|
|
|
|
|
68
|
|
|
if (false === $table->hasForeignKey('FK_62798E972395FCED')) { |
|
69
|
|
|
$this->addSql( |
|
70
|
|
|
'ALTER TABLE c_thematic_advance ADD CONSTRAINT FK_62798E972395FCED FOREIGN KEY (thematic_id) REFERENCES c_thematic (iid)' |
|
71
|
|
|
); |
|
72
|
|
|
} |
|
73
|
|
|
if (false === $table->hasForeignKey('FK_62798E97163DDA15')) { |
|
74
|
|
|
$this->addSql( |
|
75
|
|
|
'ALTER TABLE c_thematic_advance ADD CONSTRAINT FK_62798E97163DDA15 FOREIGN KEY (attendance_id) REFERENCES c_attendance (iid)' |
|
76
|
|
|
); |
|
77
|
|
|
} |
|
78
|
|
|
if (false === $table->hasIndex('IDX_62798E97163DDA15')) { |
|
79
|
|
|
$this->addSql('CREATE INDEX IDX_62798E97163DDA15 ON c_thematic_advance (attendance_id);'); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/* |
|
83
|
|
|
if (false === $table->hasColumn('resource_node_id')) { |
|
84
|
|
|
$this->addSql('ALTER TABLE c_thematic_advance ADD resource_node_id INT DEFAULT NULL'); |
|
85
|
|
|
|
|
86
|
|
|
//$this->addSql('ALTER TABLE c_thematic_advance ADD CONSTRAINT FK_62798E971BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE'); |
|
87
|
|
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_62798E971BAD783F ON c_thematic_advance (resource_node_id)'); |
|
88
|
|
|
}*/ |
|
89
|
|
|
|
|
90
|
|
|
$table = $schema->getTable('c_thematic_plan'); |
|
91
|
|
|
$this->addSql('ALTER TABLE c_thematic_plan CHANGE thematic_id thematic_id INT DEFAULT NULL'); |
|
92
|
|
|
|
|
93
|
|
|
if ($table->hasIndex('course')) { |
|
94
|
|
|
$this->addSql('DROP INDEX course ON c_thematic_plan'); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
if ($table->hasColumn('c_id')) { |
|
98
|
|
|
//$this->addSql('ALTER TABLE c_thematic_plan DROP c_id;'); |
|
99
|
|
|
} |
|
100
|
|
|
if (false === $table->hasForeignKey('FK_1197487C2395FCED')) { |
|
101
|
|
|
$this->addSql( |
|
102
|
|
|
'ALTER TABLE c_thematic_plan ADD CONSTRAINT FK_1197487C2395FCED FOREIGN KEY (thematic_id) REFERENCES c_thematic (iid)' |
|
103
|
|
|
); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
if (false === $table->hasIndex('IDX_1197487C2395FCED')) { |
|
107
|
|
|
$this->addSql('CREATE INDEX IDX_1197487C2395FCED ON c_thematic_plan (thematic_id)'); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/* |
|
111
|
|
|
if (false === $table->hasColumn('resource_node_id')) { |
|
112
|
|
|
$this->addSql('ALTER TABLE c_thematic_plan ADD resource_node_id INT DEFAULT NULL'); |
|
113
|
|
|
|
|
114
|
|
|
$this->addSql('ALTER TABLE c_thematic_plan ADD CONSTRAINT FK_1197487C1BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE'); |
|
115
|
|
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_1197487C1BAD783F ON c_thematic_plan (resource_node_id)'); |
|
116
|
|
|
}*/ |
|
117
|
|
|
|
|
118
|
|
|
// CLink |
|
119
|
|
|
$table = $schema->getTable('c_link'); |
|
120
|
|
|
if (false === $table->hasColumn('resource_node_id')) { |
|
121
|
|
|
$this->addSql('ALTER TABLE c_link ADD resource_node_id INT DEFAULT NULL;'); |
|
122
|
|
|
$this->addSql( |
|
123
|
|
|
'ALTER TABLE c_link ADD CONSTRAINT FK_9209C2A01BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE;' |
|
124
|
|
|
); |
|
125
|
|
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_9209C2A01BAD783F ON c_link (resource_node_id);'); |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
if ($table->hasIndex('session_id')) { |
|
129
|
|
|
$this->addSql('DROP INDEX session_id ON c_link'); |
|
130
|
|
|
} |
|
131
|
|
|
if ($table->hasIndex('course')) { |
|
132
|
|
|
$this->addSql('DROP INDEX course ON c_link'); |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
$this->addSql('UPDATE c_link SET category_id = NULL WHERE category_id = 0'); |
|
136
|
|
|
if (false === $table->hasForeignKey('FK_9209C2A012469DE2')) { |
|
137
|
|
|
$this->addSql( |
|
138
|
|
|
'ALTER TABLE c_link ADD CONSTRAINT FK_9209C2A012469DE2 FOREIGN KEY (category_id) REFERENCES c_link_category (iid)' |
|
139
|
|
|
); |
|
140
|
|
|
$this->addSql('CREATE INDEX IDX_9209C2A012469DE2 ON c_link (category_id)'); |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
$table = $schema->getTable('c_link_category'); |
|
144
|
|
|
if (false === $table->hasColumn('resource_node_id')) { |
|
145
|
|
|
$this->addSql('ALTER TABLE c_link_category ADD resource_node_id INT DEFAULT NULL'); |
|
146
|
|
|
$this->addSql( |
|
147
|
|
|
'ALTER TABLE c_link_category ADD CONSTRAINT FK_319D6C9C1BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE' |
|
148
|
|
|
); |
|
149
|
|
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_319D6C9C1BAD783F ON c_link_category (resource_node_id)'); |
|
150
|
|
|
} |
|
151
|
|
|
if ($table->hasIndex('session_id')) { |
|
152
|
|
|
$this->addSql('DROP INDEX session_id ON c_link_category'); |
|
153
|
|
|
} |
|
154
|
|
|
if ($table->hasIndex('course')) { |
|
155
|
|
|
$this->addSql('DROP INDEX course ON c_link_category'); |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
$table = $schema->getTable('c_glossary'); |
|
159
|
|
|
|
|
160
|
|
|
if ($table->hasIndex('course')) { |
|
161
|
|
|
$this->addSql('DROP INDEX course ON c_glossary'); |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
if ($table->hasIndex('session_id')) { |
|
165
|
|
|
$this->addSql('DROP INDEX session_id ON c_glossary'); |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
if (false === $table->hasColumn('resource_node_id')) { |
|
169
|
|
|
$this->addSql('ALTER TABLE c_glossary ADD resource_node_id INT DEFAULT NULL'); |
|
170
|
|
|
$this->addSql( |
|
171
|
|
|
'ALTER TABLE c_glossary ADD CONSTRAINT FK_A1168D881BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE' |
|
172
|
|
|
); |
|
173
|
|
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_A1168D881BAD783F ON c_glossary (resource_node_id)'); |
|
174
|
|
|
} |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
public function down(Schema $schema): void |
|
178
|
|
|
{ |
|
179
|
|
|
} |
|
180
|
|
|
} |
|
181
|
|
|
|