<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20230719085301 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add is_form_complete field for the member_application table';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->getTable('member_application')->hasColumn('is_form_complete'),
'The is_form_complete field already set in the member_application table!'
);
$schema->getTable('member_application')
->addColumn('is_form_complete', 'boolean', ['notnull' => true, 'default' => true]);
}
public function postUp(Schema $schema): void
{
$this->connection->executeQuery(
'UPDATE member_application set is_form_complete=1'
);
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->getTable('member_application')->hasColumn('is_form_complete'),
'The is_form_complete is already removed from the member_application table!'
);
$schema->getTable('member_application')->dropColumn('is_form_complete');
}
}