Migrations: Fix migrations add missing changes

pull/3733/head
Julio Montoya 4 years ago
parent 27f775eccb
commit da7d374383
  1. 4
      src/CoreBundle/Entity/ResourceComment.php
  2. 12
      src/CoreBundle/Migrations/AbstractMigrationChamilo.php
  3. 58
      src/CoreBundle/Migrations/Schema/V200/Version20170625143000.php
  4. 8
      src/CoreBundle/Migrations/Schema/V200/Version20181126174500.php
  5. 12
      src/CoreBundle/Migrations/Schema/V200/Version20190110182615.php
  6. 37
      src/CoreBundle/Migrations/Schema/V200/Version20190110182620.php
  7. 1
      src/CoreBundle/Migrations/Schema/V200/Version20201215072918.php
  8. 4
      src/CoreBundle/Migrations/Schema/V200/Version20201215142610.php
  9. 11
      src/CourseBundle/Entity/CGroup.php

@ -15,10 +15,10 @@ use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** /**
* @ApiResource( * ApiResource(
* attributes={"security"="is_granted('ROLE_ADMIN')"}, * attributes={"security"="is_granted('ROLE_ADMIN')"},
* normalizationContext={"groups"={"comment:read"}} * normalizationContext={"groups"={"comment:read"}}
* ) * ).
* *
* @Gedmo\Tree(type="nested") * @Gedmo\Tree(type="nested")
* @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\NestedTreeRepository") * @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\NestedTreeRepository")

@ -4,12 +4,14 @@
namespace Chamilo\CoreBundle\Migrations; namespace Chamilo\CoreBundle\Migrations;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\ResourceInterface; use Chamilo\CoreBundle\Entity\ResourceInterface;
use Chamilo\CoreBundle\Entity\ResourceLink; use Chamilo\CoreBundle\Entity\ResourceLink;
use Chamilo\CoreBundle\Entity\SettingsCurrent; use Chamilo\CoreBundle\Entity\SettingsCurrent;
use Chamilo\CoreBundle\Entity\SettingsOptions; use Chamilo\CoreBundle\Entity\SettingsOptions;
use Chamilo\CoreBundle\Entity\User; use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Repository\Node\UserRepository; use Chamilo\CoreBundle\Repository\Node\UserRepository;
use Chamilo\CoreBundle\Repository\ResourceRepository;
use Chamilo\CoreBundle\Repository\SessionRepository; use Chamilo\CoreBundle\Repository\SessionRepository;
use Chamilo\CourseBundle\Repository\CGroupRepository; use Chamilo\CourseBundle\Repository\CGroupRepository;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
@ -185,8 +187,14 @@ abstract class AbstractMigrationChamilo extends AbstractMigration implements Con
//to be implemented //to be implemented
} }
public function addLegacyFileToResource($filePath, $repo, $resource, $id, $fileName = '') public function addLegacyFileToResource(
{ string $filePath,
ResourceRepository $repo,
AbstractResource $resource,
$id,
$fileName = '',
$description = ''
) {
if (!is_dir($filePath)) { if (!is_dir($filePath)) {
$class = get_class($resource); $class = get_class($resource);
$documentPath = basename($filePath); $documentPath = basename($filePath);

@ -17,31 +17,57 @@ class Version20170625143000 extends AbstractMigrationChamilo
$table = $schema->getTable('c_thematic'); $table = $schema->getTable('c_thematic');
if (false === $table->hasColumn('resource_node_id')) { if (false === $table->hasColumn('resource_node_id')) {
$this->addSql('ALTER TABLE c_thematic ADD resource_node_id INT DEFAULT NULL'); $this->addSql('ALTER TABLE c_thematic ADD resource_node_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE c_thematic ADD CONSTRAINT FK_6D8F59B91BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE'); $this->addSql(
'ALTER TABLE c_thematic ADD CONSTRAINT FK_6D8F59B91BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE'
);
$this->addSql('CREATE UNIQUE INDEX UNIQ_6D8F59B91BAD783F ON c_thematic (resource_node_id)'); $this->addSql('CREATE UNIQUE INDEX UNIQ_6D8F59B91BAD783F ON c_thematic (resource_node_id)');
} }
/*$table = $schema->getTable('c_thematic_advance'); $table = $schema->getTable('c_thematic_advance');
$this->addSql('ALTER TABLE c_thematic_advance CHANGE thematic_id thematic_id INT DEFAULT NULL, CHANGE attendance_id attendance_id INT DEFAULT NULL'); $this->addSql(
'ALTER TABLE c_thematic_advance CHANGE thematic_id thematic_id INT DEFAULT NULL, CHANGE attendance_id attendance_id INT DEFAULT NULL'
);
if (false === $table->hasForeignKey('FK_62798E972395FCED')) {
$this->addSql(
'ALTER TABLE c_thematic_advance ADD CONSTRAINT FK_62798E972395FCED FOREIGN KEY (thematic_id) REFERENCES c_thematic (iid)'
);
}
if (false === $table->hasForeignKey('FK_62798E97163DDA15')) {
$this->addSql(
'ALTER TABLE c_thematic_advance ADD CONSTRAINT FK_62798E97163DDA15 FOREIGN KEY (attendance_id) REFERENCES c_attendance (iid)'
);
}
if (false === $table->hasIndex('IDX_62798E97163DDA15')) {
$this->addSql('CREATE INDEX IDX_62798E97163DDA15 ON c_thematic_advance (attendance_id);');
}
/*
if (false === $table->hasColumn('resource_node_id')) { if (false === $table->hasColumn('resource_node_id')) {
$this->addSql('ALTER TABLE c_thematic_advance ADD resource_node_id INT DEFAULT NULL'); $this->addSql('ALTER TABLE c_thematic_advance ADD resource_node_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE c_thematic_advance ADD CONSTRAINT FK_62798E972395FCED FOREIGN KEY (thematic_id) REFERENCES c_thematic (iid)');
$this->addSql('ALTER TABLE c_thematic_advance ADD CONSTRAINT FK_62798E97163DDA15 FOREIGN KEY (attendance_id) REFERENCES c_attendance (iid)');
//$this->addSql('ALTER TABLE c_thematic_advance ADD CONSTRAINT FK_62798E971BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE'); //$this->addSql('ALTER TABLE c_thematic_advance ADD CONSTRAINT FK_62798E971BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE');
$this->addSql('CREATE UNIQUE INDEX UNIQ_62798E971BAD783F ON c_thematic_advance (resource_node_id)'); $this->addSql('CREATE UNIQUE INDEX UNIQ_62798E971BAD783F ON c_thematic_advance (resource_node_id)');
}
if (false === $table->hasIndex('IDX_62798E97163DDA15')) {
$this->addSql('CREATE INDEX IDX_62798E97163DDA15 ON c_thematic_advance (attendance_id)');
}*/ }*/
/*$table = $schema->getTable('c_thematic_plan'); $table = $schema->getTable('c_thematic_plan');
$this->addSql('ALTER TABLE c_thematic_plan CHANGE thematic_id thematic_id INT DEFAULT NULL'); $this->addSql('ALTER TABLE c_thematic_plan CHANGE thematic_id thematic_id INT DEFAULT NULL');
if (false === $table->hasForeignKey('FK_1197487C2395FCED')) {
$this->addSql(
'ALTER TABLE c_thematic_plan ADD CONSTRAINT FK_1197487C2395FCED FOREIGN KEY (thematic_id) REFERENCES c_thematic (iid)'
);
}
if (false === $table->hasIndex('IDX_1197487C2395FCED')) {
$this->addSql('CREATE INDEX IDX_1197487C2395FCED ON c_thematic_plan (thematic_id)');
}
/*
if (false === $table->hasColumn('resource_node_id')) { if (false === $table->hasColumn('resource_node_id')) {
$this->addSql('ALTER TABLE c_thematic_plan ADD resource_node_id INT DEFAULT NULL'); $this->addSql('ALTER TABLE c_thematic_plan ADD resource_node_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE c_thematic_plan ADD CONSTRAINT FK_1197487C2395FCED FOREIGN KEY (thematic_id) REFERENCES c_thematic (iid)');
$this->addSql('ALTER TABLE c_thematic_plan ADD CONSTRAINT FK_1197487C1BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE c_thematic_plan ADD CONSTRAINT FK_1197487C1BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_1197487C2395FCED ON c_thematic_plan (thematic_id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_1197487C1BAD783F ON c_thematic_plan (resource_node_id)'); $this->addSql('CREATE UNIQUE INDEX UNIQ_1197487C1BAD783F ON c_thematic_plan (resource_node_id)');
}*/ }*/
@ -125,8 +151,12 @@ class Version20170625143000 extends AbstractMigrationChamilo
*/ */
if (false === $schema->hasTable('c_student_publication_correction')) { if (false === $schema->hasTable('c_student_publication_correction')) {
$this->addSql('CREATE TABLE c_student_publication_correction (id INT AUTO_INCREMENT NOT NULL, resource_node_id INT DEFAULT NULL, title VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_B7309BBA1BAD783F (resource_node_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC'); $this->addSql(
$this->addSql('ALTER TABLE c_student_publication_correction ADD CONSTRAINT FK_B7309BBA1BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE;'); 'CREATE TABLE c_student_publication_correction (id INT AUTO_INCREMENT NOT NULL, resource_node_id INT DEFAULT NULL, title VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_B7309BBA1BAD783F (resource_node_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC'
);
$this->addSql(
'ALTER TABLE c_student_publication_correction ADD CONSTRAINT FK_B7309BBA1BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE;'
);
} }
$table = $schema->getTable('c_student_publication_comment'); $table = $schema->getTable('c_student_publication_comment');

@ -7,11 +7,13 @@ namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo; use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
/**
* LTI.
*/
class Version20181126174500 extends AbstractMigrationChamilo class Version20181126174500 extends AbstractMigrationChamilo
{ {
public function getDescription(): string
{
return 'Migrate plugin_ims_lti_tool';
}
public function up(Schema $schema): void public function up(Schema $schema): void
{ {
if ($schema->hasTable('plugin_ims_lti_tool')) { if ($schema->hasTable('plugin_ims_lti_tool')) {

@ -7,11 +7,13 @@ namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo; use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
/**
* LPs.
*/
class Version20190110182615 extends AbstractMigrationChamilo class Version20190110182615 extends AbstractMigrationChamilo
{ {
public function getDescription(): string
{
return 'Migrate c_lp';
}
public function up(Schema $schema): void public function up(Schema $schema): void
{ {
$this->addSql('ALTER TABLE c_lp CHANGE author author LONGTEXT NOT NULL'); $this->addSql('ALTER TABLE c_lp CHANGE author author LONGTEXT NOT NULL');
@ -138,8 +140,4 @@ class Version20190110182615 extends AbstractMigrationChamilo
); );
} }
} }
public function down(Schema $schema): void
{
}
} }

@ -0,0 +1,37 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
class Version20190110182615 extends AbstractMigrationChamilo
{
public function getDescription(): string
{
return 'Migrate c_blog, c_wiki';
}
public function up(Schema $schema): void
{
$table = $schema->getTable('c_blog');
if (false === $table->hasColumn('resource_node_id')) {
$this->addSql('ALTER TABLE c_blog ADD resource_node_id INT DEFAULT NULL;');
$this->addSql(
'ALTER TABLE c_blog ADD CONSTRAINT FK_64B00A121BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE;'
);
$this->addSql('CREATE UNIQUE INDEX UNIQ_64B00A121BAD783F ON c_blog (resource_node_id);');
}
$table = $schema->getTable('c_wiki');
if (false === $table->hasColumn('resource_node_id')) {
$this->addSql('ALTER TABLE c_wiki ADD resource_node_id INT DEFAULT NULL;');
$this->addSql(
'ALTER TABLE c_wiki ADD CONSTRAINT FK_866887571BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE;'
);
$this->addSql('CREATE UNIQUE INDEX UNIQ_866887571BAD783F ON c_wiki (resource_node_id);');
}
}
}

@ -91,7 +91,6 @@ final class Version20201215072918 extends AbstractMigrationChamilo
if (null === $parent) { if (null === $parent) {
$parent = $course; $parent = $course;
} }
$result = $this->fixItemProperty('calendar_event', $eventRepo, $course, $admin, $event, $parent);
if (false === $result) { if (false === $result) {
continue; continue;

@ -26,7 +26,7 @@ final class Version20201215142610 extends AbstractMigrationChamilo
{ {
public function getDescription(): string public function getDescription(): string
{ {
return 'Migrate c_quiz'; return 'Migrate c_quiz, c_quiz_question_category, c_quiz_question';
} }
public function up(Schema $schema): void public function up(Schema $schema): void
@ -115,7 +115,7 @@ final class Version20201215142610 extends AbstractMigrationChamilo
$em->flush(); $em->flush();
$em->clear(); $em->clear();
// Question categories // Question categories.
$sql = "SELECT * FROM c_quiz_question_category WHERE c_id = $courseId $sql = "SELECT * FROM c_quiz_question_category WHERE c_id = $courseId
ORDER BY iid"; ORDER BY iid";
$result = $connection->executeQuery($sql); $result = $connection->executeQuery($sql);

@ -11,16 +11,21 @@ use Chamilo\CoreBundle\Entity\User;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** /**
* @ApiResource(
* attributes={"security"="is_granted('ROLE_ADMIN')"},
* normalizationContext={"groups"={"group:read"}},
* )
*
* @ORM\Table( * @ORM\Table(
* name="c_group_info", * name="c_group_info",
* indexes={ * indexes={
* } * }
* ) * )
* *
* @ApiResource()
* @ORM\Entity * @ORM\Entity
*/ */
class CGroup extends AbstractResource implements ResourceInterface class CGroup extends AbstractResource implements ResourceInterface
@ -31,6 +36,7 @@ class CGroup extends AbstractResource implements ResourceInterface
* @ORM\Column(name="iid", type="integer") * @ORM\Column(name="iid", type="integer")
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue * @ORM\GeneratedValue
* @Groups({"group:read", "group:write"})
*/ */
protected $iid; protected $iid;
@ -38,12 +44,13 @@ class CGroup extends AbstractResource implements ResourceInterface
* @var string * @var string
* @Assert\NotBlank() * @Assert\NotBlank()
* @ORM\Column(name="name", type="string", length=100, nullable=true) * @ORM\Column(name="name", type="string", length=100, nullable=true)
* @Groups({"group:read", "group:write"})
*/ */
protected $name; protected $name;
/** /**
* @var bool * @var bool
* * @Assert\NotBlank()
* @ORM\Column(name="status", type="boolean", nullable=true) * @ORM\Column(name="status", type="boolean", nullable=true)
*/ */
protected $status; protected $status;

Loading…
Cancel
Save