<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20221219161113 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add automaticMemberApplicationAccept to companies - part 2';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->getTable('company')->getColumn('automatic_member_application_accept')->getNotnull(),
'The automatic_member_application_accept field already set to not null!'
);
$schema->getTable('company')
->getColumn('automatic_member_application_accept')
->setNotnull(true);
}
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')
->getColumn('automatic_member_application_accept')
->setNotnull(false);
}
}