Internal: Migration: remove double migration files with Version20201211124910.php and Version20201211114910.php -refs BT#20864
parent
6ccdc7aa26
commit
5878d9c170
@ -1,52 +0,0 @@ |
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Chamilo\CoreBundle\Migrations\Schema\V200; |
||||
|
||||
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo; |
||||
use Doctrine\DBAL\Schema\Schema; |
||||
|
||||
final class Version20230306145019 extends AbstractMigrationChamilo |
||||
{ |
||||
public function getDescription(): string |
||||
{ |
||||
return 'Create table resource_format'; |
||||
} |
||||
|
||||
public function up(Schema $schema): void |
||||
{ |
||||
if (!$schema->hasTable('resource_format')) { |
||||
$this->addSql( |
||||
"CREATE TABLE resource_format (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) 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;" |
||||
); |
||||
$this->addSql( |
||||
'ALTER TABLE resource_node ADD resource_format_id INT DEFAULT NULL;' |
||||
); |
||||
$this->addSql( |
||||
'ALTER TABLE resource_node ADD CONSTRAINT FK_8A5F48FF7EE0A59A FOREIGN KEY (resource_format_id) REFERENCES resource_format (id) ON DELETE SET NULL;' |
||||
); |
||||
$this->addSql( |
||||
'CREATE INDEX IDX_8A5F48FF7EE0A59A ON resource_node (resource_format_id);' |
||||
); |
||||
} |
||||
} |
||||
|
||||
public function down(Schema $schema): void |
||||
{ |
||||
if ($schema->hasTable('resource_format')) { |
||||
$this->addSql( |
||||
'ALTER TABLE resource_node DROP FOREIGN KEY FK_8A5F48FF7EE0A59A;' |
||||
); |
||||
$this->addSql( |
||||
'ALTER TABLE resource_node DROP INDEX IDX_8A5F48FF7EE0A59A;' |
||||
); |
||||
$this->addSql( |
||||
'ALTER TABLE resource_node DROP resource_format_id;' |
||||
); |
||||
$this->addSql( |
||||
'DROP TABLE resource_format;' |
||||
); |
||||
} |
||||
} |
||||
} |
@ -1,50 +0,0 @@ |
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Chamilo\CoreBundle\Migrations\Schema\V200; |
||||
|
||||
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo; |
||||
use Doctrine\DBAL\Schema\Schema; |
||||
|
||||
final class Version20230306150219 extends AbstractMigrationChamilo |
||||
{ |
||||
public function getDescription(): string |
||||
{ |
||||
return 'Insert default values to table resource_format'; |
||||
} |
||||
|
||||
public function up(Schema $schema): void |
||||
{ |
||||
$connection = $this->getEntityManager()->getConnection(); |
||||
if ($schema->hasTable('resource_format')) { |
||||
$result = $connection->executeQuery(" SELECT * FROM resource_format WHERE title = 'html'"); |
||||
$exists = $result->fetchAllAssociative(); |
||||
if (empty($exists)) { |
||||
$this->addSql("INSERT INTO resource_format SET title = 'html', created_at = NOW(), updated_at = NOW();"); |
||||
} |
||||
$result = $connection->executeQuery(" SELECT * FROM resource_format WHERE title = 'txt'"); |
||||
$exists = $result->fetchAllAssociative(); |
||||
if (empty($exists)) { |
||||
$this->addSql("INSERT INTO resource_format SET title = 'txt', created_at = NOW(), updated_at = NOW();"); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public function down(Schema $schema): void |
||||
{ |
||||
$connection = $this->getEntityManager()->getConnection(); |
||||
if ($schema->hasTable('resource_format')) { |
||||
$result = $connection->executeQuery(" SELECT * FROM resource_format WHERE title = 'txt'"); |
||||
$exists = $result->fetchAllAssociative(); |
||||
if (!empty($exists)) { |
||||
$this->addSql("DELETE FROM resource_format WHERE title = 'txt';"); |
||||
} |
||||
$result = $connection->executeQuery(" SELECT * FROM resource_format WHERE title = 'html'"); |
||||
$exists = $result->fetchAllAssociative(); |
||||
if (!empty($exists)) { |
||||
$this->addSql("DELETE FROM resource_format WHERE title = 'html';"); |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue