Migrations: Fix queries

pull/3984/head
Julio 4 years ago
parent 14e06d1d59
commit 4e15f58338
  1. 2
      src/CoreBundle/Migrations/AbstractMigrationChamilo.php
  2. 6
      src/CoreBundle/Migrations/Schema/V200/Version20180928172830.php
  3. 2
      src/CoreBundle/Migrations/Schema/V200/Version20201212195011.php
  4. 3
      src/CoreBundle/Migrations/Schema/V200/Version20201215153517.php

@ -238,7 +238,7 @@ abstract class AbstractMigrationChamilo extends AbstractMigration implements Con
$items = $result->fetchAllAssociative(); $items = $result->fetchAllAssociative();
} }
// For some reason the resource doesnt have a c_item_property value. // For some reason the resource doesn't have a c_item_property value.
if (empty($items)) { if (empty($items)) {
return false; return false;
} }

@ -34,10 +34,10 @@ class Version20180928172830 extends AbstractMigrationChamilo
//$this->addSql('UPDATE c_tool SET name = "assignment" WHERE name = "student_publication" '); //$this->addSql('UPDATE c_tool SET name = "assignment" WHERE name = "student_publication" ');
//$this->addSql('UPDATE c_tool SET name = "settings" WHERE name = "course_setting" '); //$this->addSql('UPDATE c_tool SET name = "settings" WHERE name = "course_setting" ');
if (false === $table->hasColumn('tool_id')) { if (!$table->hasColumn('tool_id')) {
$this->addSql('ALTER TABLE c_tool ADD tool_id INT NOT NULL'); $this->addSql('ALTER TABLE c_tool ADD tool_id INT NOT NULL');
} }
if (false === $table->hasColumn('position')) { if (!$table->hasColumn('position')) {
$this->addSql('ALTER TABLE c_tool ADD position INT NOT NULL'); $this->addSql('ALTER TABLE c_tool ADD position INT NOT NULL');
} }
@ -75,8 +75,6 @@ class Version20180928172830 extends AbstractMigrationChamilo
// @todo remove/move LP/Link shortcuts. // @todo remove/move LP/Link shortcuts.
$this->addSql('DELETE FROM c_tool WHERE tool_id = 0 OR tool_id IS NULL'); $this->addSql('DELETE FROM c_tool WHERE tool_id = 0 OR tool_id IS NULL');
$this->addSql('UPDATE c_tool SET session_id = NULL WHERE session_id = 0 ');
$this->addSql('DELETE FROM c_tool WHERE session_id IS NOT NULL AND session_id NOT IN (SELECT id FROM session)'); $this->addSql('DELETE FROM c_tool WHERE session_id IS NOT NULL AND session_id NOT IN (SELECT id FROM session)');
if (!$table->hasForeignKey('FK_84566580613FECDF')) { if (!$table->hasForeignKey('FK_84566580613FECDF')) {

@ -105,7 +105,7 @@ final class Version20201212195011 extends AbstractMigrationChamilo
$admin = $this->getAdmin(); $admin = $this->getAdmin();
$tool->setParent($course); $tool->setParent($course);
$toolRepo->addResourceNode($tool, $admin, $course); $toolRepo->addResourceNode($tool, $admin, $course);
$newVisibility = 1 === $toolData['visibility'] ? ResourceLink::VISIBILITY_PUBLISHED : ResourceLink::VISIBILITY_PENDING; $newVisibility = 1 === (int) $toolData['visibility'] ? ResourceLink::VISIBILITY_PUBLISHED : ResourceLink::VISIBILITY_PENDING;
$tool->addCourseLink($course, $session, null, $newVisibility); $tool->addCourseLink($course, $session, null, $newVisibility);
$em->persist($tool); $em->persist($tool);
if (($counter % $batchSize) === 0) { if (($counter % $batchSize) === 0) {

@ -116,6 +116,9 @@ final class Version20201215153517 extends AbstractMigrationChamilo
$em->persist($resource); $em->persist($resource);
$em->flush(); $em->flush();
} }
$em->flush();
$em->clear();
} }
} }
} }

Loading…
Cancel
Save