|
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_calendar_event. |
|
14
|
|
|
*/ |
|
15
|
|
|
class Version20170625145000 extends AbstractMigrationChamilo |
|
16
|
|
|
{ |
|
17
|
|
|
public function up(Schema $schema): void |
|
18
|
|
|
{ |
|
19
|
|
|
$table = $schema->getTable('c_calendar_event'); |
|
20
|
|
|
if (false === $table->hasColumn('resource_node_id')) { |
|
21
|
|
|
$this->addSql('ALTER TABLE c_calendar_event ADD resource_node_id INT DEFAULT NULL'); |
|
22
|
|
|
$this->addSql( |
|
23
|
|
|
'ALTER TABLE c_calendar_event ADD CONSTRAINT FK_A0622581EE3A445A FOREIGN KEY (parent_event_id) REFERENCES c_calendar_event (iid)' |
|
24
|
|
|
); |
|
25
|
|
|
$this->addSql( |
|
26
|
|
|
'ALTER TABLE c_calendar_event ADD CONSTRAINT FK_A06225811BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE' |
|
27
|
|
|
); |
|
28
|
|
|
$this->addSql('CREATE INDEX IDX_A0622581EE3A445A ON c_calendar_event (parent_event_id)'); |
|
29
|
|
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_A06225811BAD783F ON c_calendar_event (resource_node_id)'); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
if ($table->hasIndex('course')) { |
|
33
|
|
|
$this->addSql('DROP INDEX course ON c_calendar_event'); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
if ($table->hasIndex('session_id')) { |
|
37
|
|
|
$this->addSql('DROP INDEX session_id ON c_calendar_event'); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
$table = $schema->getTable('c_calendar_event_attachment'); |
|
41
|
|
|
if ($table->hasIndex('course')) { |
|
42
|
|
|
$this->addSql('DROP INDEX course ON c_calendar_event_attachment'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
$this->addSql('ALTER TABLE c_calendar_event_attachment CHANGE agenda_id agenda_id INT DEFAULT NULL'); |
|
46
|
|
|
|
|
47
|
|
|
if (false === $table->hasColumn('resource_node_id')) { |
|
48
|
|
|
$this->addSql('ALTER TABLE c_calendar_event_attachment ADD resource_node_id INT DEFAULT NULL'); |
|
49
|
|
|
$this->addSql( |
|
50
|
|
|
'ALTER TABLE c_calendar_event_attachment ADD CONSTRAINT FK_DDD745A6EA67784A FOREIGN KEY (agenda_id) REFERENCES c_calendar_event (iid) ON DELETE CASCADE' |
|
51
|
|
|
); |
|
52
|
|
|
$this->addSql( |
|
53
|
|
|
'ALTER TABLE c_calendar_event_attachment ADD CONSTRAINT FK_DDD745A61BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE' |
|
54
|
|
|
); |
|
55
|
|
|
$this->addSql('CREATE INDEX IDX_DDD745A6EA67784A ON c_calendar_event_attachment (agenda_id)'); |
|
56
|
|
|
$this->addSql( |
|
57
|
|
|
'CREATE UNIQUE INDEX UNIQ_DDD745A61BAD783F ON c_calendar_event_attachment (resource_node_id)' |
|
58
|
|
|
); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
$table = $schema->getTable('c_calendar_event_repeat'); |
|
62
|
|
|
$this->addSql('ALTER TABLE c_calendar_event_repeat CHANGE cal_id cal_id INT DEFAULT NULL'); |
|
63
|
|
|
if (false === $table->hasForeignKey('FK_86FD1CA87300D633')) { |
|
64
|
|
|
$this->addSql( |
|
65
|
|
|
'ALTER TABLE c_calendar_event_repeat ADD CONSTRAINT FK_86FD1CA87300D633 FOREIGN KEY (cal_id) REFERENCES c_calendar_event (iid)' |
|
66
|
|
|
); |
|
67
|
|
|
} |
|
68
|
|
|
if (false === $table->hasIndex('IDX_86FD1CA87300D633')) { |
|
69
|
|
|
$this->addSql('CREATE INDEX IDX_86FD1CA87300D633 ON c_calendar_event_repeat (cal_id)'); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
if ($table->hasIndex('course')) { |
|
73
|
|
|
$this->addSql('DROP INDEX course ON c_calendar_event_repeat'); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
$table = $schema->getTable('c_calendar_event_repeat_not'); |
|
77
|
|
|
|
|
78
|
|
|
if ($table->hasIndex('course')) { |
|
79
|
|
|
$this->addSql('DROP INDEX course ON c_calendar_event_repeat_not'); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
if (false === $table->hasForeignKey('FK_7D4436947300D633')) { |
|
83
|
|
|
$this->addSql( |
|
84
|
|
|
'ALTER TABLE c_calendar_event_repeat_not ADD CONSTRAINT FK_7D4436947300D633 FOREIGN KEY (cal_id) REFERENCES c_calendar_event (iid)' |
|
85
|
|
|
); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
$this->addSql('ALTER TABLE c_calendar_event_repeat_not CHANGE cal_id cal_id INT DEFAULT NULL'); |
|
89
|
|
|
|
|
90
|
|
|
if (false === $table->hasIndex('IDX_7D4436947300D633')) { |
|
91
|
|
|
$this->addSql('CREATE INDEX IDX_7D4436947300D633 ON c_calendar_event_repeat_not (cal_id)'); |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
public function down(Schema $schema): void |
|
96
|
|
|
{ |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|