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