<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20221019132958 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add max_age and is_default fields to the health_mutual table';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->getTable('health_mutual')->hasColumn('max_age'),
'The max_age field already exists in the health_mutual table!'
);
$schema->getTable('health_mutual')
->addColumn('max_age', Types::INTEGER)->setNotnull(false);
$schema->getTable('health_mutual')
->addColumn('is_default', Types::BOOLEAN)->setNotnull(true)->setDefault(false);
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->getTable('health_mutual')->hasColumn('max_age'),
'The max_age is already removed from the health_mutual table!'
);
$schema->getTable('health_mutual')
->dropColumn('max_age');
$schema->getTable('health_mutual')
->dropColumn('is_default');
}
}