Merge pull request #5388 from christianbeeznest/fixes-updates23

Internal: Update migration validations
pull/5390/head
christianbeeznest 1 year ago committed by GitHub
commit 1de90c01f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      src/CoreBundle/Migrations/Schema/V200/Version20201212114900.php
  2. 34
      src/CoreBundle/Migrations/Schema/V200/Version20240413234500.php

@ -9,7 +9,7 @@ namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
class Version20240414014200 extends AbstractMigrationChamilo
class Version20201212114900 extends AbstractMigrationChamilo
{
public function getDescription(): string
{

@ -26,13 +26,21 @@ final class Version20240413234500 extends AbstractMigrationChamilo
}
if ($schema->hasTable('portfolio_comment')) {
$this->addSql('ALTER TABLE portfolio_comment ADD visibility SMALLINT DEFAULT 1 NOT NULL');
$table = $schema->getTable('portfolio_comment');
if (!$table->hasColumn('visibility')) {
$this->addSql('ALTER TABLE portfolio_comment ADD visibility SMALLINT DEFAULT 1 NOT NULL');
}
}
if ($schema->hasTable('portfolio_category')) {
$this->addSql('ALTER TABLE portfolio_category ADD parent_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE portfolio_category ADD CONSTRAINT FK_7AC64359727ACA70 FOREIGN KEY (parent_id) REFERENCES portfolio_category (id) ON DELETE SET NULL');
$this->addSql('CREATE INDEX IDX_7AC64359727ACA70 ON portfolio_category (parent_id)');
$table = $schema->getTable('portfolio_category');
if (!$table->hasColumn('parent_id')) {
$this->addSql('ALTER TABLE portfolio_category ADD parent_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE portfolio_category ADD CONSTRAINT FK_7AC64359727ACA70 FOREIGN KEY (parent_id) REFERENCES portfolio_category (id) ON DELETE SET NULL');
}
if (!$table->hasIndex('IDX_7AC64359727ACA70')) {
$this->addSql('CREATE INDEX IDX_7AC64359727ACA70 ON portfolio_category (parent_id)');
}
}
}
@ -43,13 +51,23 @@ final class Version20240413234500 extends AbstractMigrationChamilo
}
if ($schema->hasTable('portfolio_comment')) {
$this->addSql('ALTER TABLE portfolio_comment DROP COLUMN visibility');
$table = $schema->getTable('portfolio_comment');
if ($table->hasColumn('visibility')) {
$this->addSql('ALTER TABLE portfolio_comment DROP COLUMN visibility');
}
}
if ($schema->hasTable('portfolio_category')) {
$this->addSql('ALTER TABLE portfolio_category DROP FOREIGN KEY FK_7AC64359727ACA70');
$this->addSql('ALTER TABLE portfolio_category DROP COLUMN parent_id');
$this->addSql('DROP INDEX IDX_7AC64359727ACA70 ON portfolio_category');
$table = $schema->getTable('portfolio_category');
if ($table->hasForeignKey('FK_7AC64359727ACA70')) {
$this->addSql('ALTER TABLE portfolio_category DROP FOREIGN KEY FK_7AC64359727ACA70');
}
if ($table->hasColumn('parent_id')) {
$this->addSql('ALTER TABLE portfolio_category DROP COLUMN parent_id');
}
if ($table->hasIndex('IDX_7AC64359727ACA70')) {
$this->addSql('DROP INDEX IDX_7AC64359727ACA70 ON portfolio_category');
}
}
}
}

Loading…
Cancel
Save