Internal: Migration: Transfer records from track_e_attempt_recording to track_e_attempt_qualify and drop old table

pull/5095/head
christianbeeznst 10 months ago
parent 38ef378d06
commit 11d13fcdb4
  1. 18
      src/CoreBundle/Migrations/Schema/V200/Version20230321164019.php
  2. 31
      src/CoreBundle/Migrations/Schema/V200/Version20240117134009.php

@ -7,6 +7,7 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Entity\TrackEAttemptQualify;
use Chamilo\CoreBundle\Entity\TrackEExercise;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
@ -29,19 +30,24 @@ class Version20230321164019 extends AbstractMigrationChamilo
$items = $result->fetchAllAssociative();
foreach ($items as $item) {
$trackQualify = new TrackEAttemptQualify();
$trackQualify
->setExeId($item['exe_id'])
$attemptQualify = new TrackEAttemptQualify();
$attemptQualify
->setQuestionId($item['question_id'])
->setAnswer($item['answer'])
->setMarks((int) $item['marks'])
->setMarks($item['marks'])
->setAuthor($item['author'])
->setTeacherComment($item['teacher_comment'])
->setSessionId($item['session_id'])
;
$em->persist($trackQualify);
$em->flush();
$trackEExercise = $em->getRepository(TrackEExercise::class)->find($item['exe_id']);
if ($trackEExercise) {
$attemptQualify->setTrackExercise($trackEExercise);
$em->persist($attemptQualify);
}
}
$em->flush();
}
public function down(Schema $schema): void {}

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
class Version20240117134009 extends AbstractMigrationChamilo
{
public function getDescription(): string
{
return 'Remove table track_e_attempt_recording';
}
public function up(Schema $schema): void
{
$this->addSql('DROP TABLE IF EXISTS track_e_attempt_recording');
}
public function down(Schema $schema): void
{
$this->addSql('CREATE TABLE track_e_attempt_recording (id INT AUTO_INCREMENT NOT NULL, exe_id INT NOT NULL, question_id INT NOT NULL, marks DOUBLE PRECISION NOT NULL, insert_date DATETIME NOT NULL, author INT NOT NULL, teacher_comment LONGTEXT NOT NULL, session_id INT NOT NULL, answer LONGTEXT DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE INDEX exe_id ON track_e_attempt_recording (exe_id)');
$this->addSql('CREATE INDEX question_id ON track_e_attempt_recording (question_id)');
$this->addSql('CREATE INDEX session_id ON track_e_attempt_recording (session_id)');
}
}
Loading…
Cancel
Save