Passed
Push — master ( 2a0c4b...cf1b71 )
by Angel Fernando Quiroz
07:25 queued 23s
created

Version20240425192900::up()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 8
nc 2
nop 1
dl 0
loc 13
rs 10
c 1
b 0
f 1
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
6
7
use Doctrine\DBAL\Schema\Schema;
8
use Doctrine\Migrations\AbstractMigration;
9
10
class Version20240425192900 extends AbstractMigration
11
{
12
    public function getDescription(): string
13
    {
14
        return 'Changes on the agenda_reminder structure';
15
    }
16
17
    /**
18
     * @inheritDoc
19
     */
20
    public function up(Schema $schema): void
21
    {
22
        if (!$schema->hasTable('agenda_reminder')) {
23
            $this->addSql(
24
                'CREATE TABLE agenda_reminder (id INT AUTO_INCREMENT NOT NULL, event_id INT NOT NULL, date_interval VARCHAR(255) NOT NULL COMMENT "(DC2Type:dateinterval)", sent TINYINT(1) NOT NULL, created_at DATETIME NOT NULL COMMENT "(DC2Type:datetime)", updated_at DATETIME NOT NULL COMMENT "(DC2Type:datetime)", PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC;'
25
            );
26
        } else {
27
            $this->addSql('ALTER TABLE agenda_reminder DROP type');
28
            $this->addSql('ALTER TABLE agenda_reminder CHANGE id id INT AUTO_INCREMENT NOT NULL;');
29
        }
30
31
        $this->addSql('ALTER TABLE agenda_reminder ADD CONSTRAINT FK_416FFA2471F7E88B FOREIGN KEY (event_id) REFERENCES c_calendar_event (iid)');
32
        $this->addSql('CREATE INDEX IDX_416FFA2471F7E88B ON agenda_reminder (event_id)');
33
    }
34
}