<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20230327150500 extends AbstractMigration
{
public function getDescription(): string
{
return 'Update is_condition_accepted field to is_general_condition_accepted the member_application table';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->getTable('member_application')->hasColumn('is_general_condition_accepted'),
'The is_general_condition_accepted field already set in the member_application table!'
);
$schema->getTable('member_application')
->addColumn('is_general_condition_accepted', Types::BOOLEAN)
->setNotnull(true)
->setDefault(false);
}
public function postUp(Schema $schema): void
{
$this->connection->executeQuery('UPDATE member_application SET is_general_condition_accepted=is_condition_accepted');
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->getTable('member_application')->hasColumn('is_general_condition_accepted'),
'The is_general_condition_accepted is already removed from the member_application table!'
);
$schema->getTable('member_application')->dropColumn('is_general_condition_accepted');
}
}