<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20230602170101 extends AbstractMigration
{
public function getDescription(): string
{
return 'Change is_removed to is_enabled field for the health_mutual table';
}
public function up(Schema $schema): void
{
$this->skipIf(
false === $schema->getTable('health_mutual')->hasColumn('is_removed'),
'The is_removed field already removed from the health_mutual table!'
);
$schema->getTable('health_mutual')->dropColumn('is_removed');
}
public function down(Schema $schema): void
{
$this->skipIf(
true === $schema->getTable('health_mutual')->hasColumn('is_removed'),
'The is_removed is already set in the health_mutual table!'
);
$schema->getTable('health_mutual')
->addColumn('is_removed', Types::BOOLEAN, ['notnull' => true, 'default' => false]);
}
public function postDown(Schema $schema): void
{
$this->connection->executeQuery('UPDATE health_mutual SET is_removed=0 WHERE is_enabled=1');
$this->connection->executeQuery('UPDATE health_mutual SET is_removed=1 WHERE is_enabled=0');
}
}