Agenda: Internal: Move migration for agenda_reminder structure and add FK from events - refs BT#21562

pull/5437/head
Angel Fernando Quiroz Campos 2 years ago
parent 2ead5f6c1e
commit d8e80b9fa9
  1. 4
      src/CoreBundle/Migrations/Schema/V200/Version20201215072918.php
  2. 8
      src/CoreBundle/Migrations/Schema/V200/Version20230216122950.php
  3. 5
      src/CoreBundle/Migrations/Schema/V200/Version20230904173400.php
  4. 5
      src/CoreBundle/Migrations/Schema/V200/Version20240112131200.php
  5. 34
      src/CoreBundle/Migrations/Schema/V200/Version20240425192900.php

@ -133,7 +133,9 @@ final class Version20201215072918 extends AbstractMigrationChamilo
}
}
$this->updateAgendaReminders($oldNewEventMap);
if ($schema->hasTable('agenda_reminder')) {
$this->updateAgendaReminders($oldNewEventMap);
}
}
/**

@ -60,14 +60,6 @@ final class Version20230216122950 extends AbstractMigrationChamilo
}
}
if (!$schema->hasTable('agenda_reminder')) {
$this->addSql(
'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;'
);
} else {
$this->addSql('ALTER TABLE agenda_reminder DROP type');
}
if (!$schema->hasTable('notification_event_rel_user')) {
$this->addSql('CREATE TABLE notification_event_rel_user (
id INT UNSIGNED AUTO_INCREMENT NOT NULL,

@ -123,7 +123,10 @@ class Version20230904173400 extends AbstractMigrationChamilo
}
$this->entityManager->flush();
$this->updateAgendaReminders($oldNewEventIdMap);
if ($schema->hasTable('agenda_reminder')) {
$this->updateAgendaReminders($oldNewEventIdMap);
}
}
private function getPersonalEvents(): array

@ -115,11 +115,6 @@ final class Version20240112131200 extends AbstractMigrationChamilo
$this->addSql('ALTER TABLE message_feedback CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE message_id message_id INT NOT NULL;');
}
if ($schema->hasTable('agenda_reminder')) {
error_log('Perform the changes in the agenda_reminder table');
$this->addSql('ALTER TABLE agenda_reminder CHANGE id id INT AUTO_INCREMENT NOT NULL;');
}
if ($schema->hasTable('c_quiz_rel_category')) {
error_log('Perform the changes in the c_quiz_rel_category table');
$this->addSql('ALTER TABLE c_quiz_rel_category CHANGE iid iid INT AUTO_INCREMENT NOT NULL;');

@ -0,0 +1,34 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
class Version20240425192900 extends AbstractMigration
{
public function getDescription(): string
{
return 'Changes on the agenda_reminder structure';
}
/**
* @inheritDoc
*/
public function up(Schema $schema): void
{
if (!$schema->hasTable('agenda_reminder')) {
$this->addSql(
'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;'
);
} else {
$this->addSql('ALTER TABLE agenda_reminder DROP type');
$this->addSql('ALTER TABLE agenda_reminder CHANGE id id INT AUTO_INCREMENT NOT NULL;');
}
$this->addSql('ALTER TABLE agenda_reminder ADD CONSTRAINT FK_416FFA2471F7E88B FOREIGN KEY (event_id) REFERENCES c_calendar_event (iid)');
$this->addSql('CREATE INDEX IDX_416FFA2471F7E88B ON agenda_reminder (event_id)');
}
}
Loading…
Cancel
Save