Passed
Push — master ( 8d1a37...25babe )
by Julito
22:45
created

Version20180904180000::up()   A

Complexity

Conditions 5
Paths 16

Size

Total Lines 24
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
cc 5
eloc 13
nc 16
nop 1
dl 0
loc 24
rs 9.5222
c 1
b 1
f 1
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
class Version20180904180000 extends AbstractMigrationChamilo
13
{
14
    public function getDescription(): string
15
    {
16
        return 'Migrate sys_calendar';
17
    }
18
19
    public function up(Schema $schema): void
20
    {
21
        $table = $schema->getTable('sys_calendar');
22
23
        $this->addSql('ALTER TABLE sys_calendar CHANGE access_url_id access_url_id INT DEFAULT NULL');
24
25
        if (!$table->hasForeignKey('FK_1670370E73444FD5')) {
26
            $this->addSql('ALTER TABLE sys_calendar ADD CONSTRAINT FK_1670370E73444FD5 FOREIGN KEY (access_url_id) REFERENCES access_url (id) ON DELETE CASCADE');
27
        }
28
29
        if (!$table->hasIndex('IDX_1670370E73444FD5')) {
30
            $this->addSql('CREATE INDEX IDX_1670370E73444FD5 ON sys_calendar (access_url_id)');
31
        }
32
33
        $table = $schema->getTable('sys_announcement');
34
35
        $this->addSql('ALTER TABLE sys_announcement CHANGE access_url_id access_url_id INT DEFAULT NULL');
36
        if (!$table->hasForeignKey('FK_E4A3EAD473444FD5')) {
37
            $this->addSql(
38
                'ALTER TABLE sys_announcement ADD CONSTRAINT FK_E4A3EAD473444FD5 FOREIGN KEY (access_url_id) REFERENCES access_url (id) ON DELETE CASCADE'
39
            );
40
        }
41
        if (!$table->hasIndex('IDX_E4A3EAD473444FD5')) {
42
            $this->addSql('CREATE INDEX IDX_E4A3EAD473444FD5 ON sys_announcement (access_url_id)');
43
        }
44
    }
45
46
    public function down(Schema $schema): void
47
    {
48
    }
49
}
50