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