<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20221222113506 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add short_code and export_id to health_insurance';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->getTable('health_insurance')->hasIndex('uniq_health_insurance_short_code'),
'The short_code field already exists in the health_insurance table!'
);
$schema->getTable('health_insurance')
->getColumn('short_code')
->setNotnull(true);
$schema->getTable('health_insurance')->addIndex(
['short_code'],
'uniq_health_insurance_short_code'
);
$schema->getTable('health_insurance')
->getColumn('export_id')
->setNotnull(true);
$schema->getTable('health_insurance')->addIndex(
['export_id'],
'uniq_health_insurance_export_id'
);
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->getTable('health_insurance')->hasIndex('uniq_health_insurance_short_code'),
'The short_code field already exists in the health_insurance table!'
);
$schema->getTable('health_insurance')->dropIndex('uniq_health_insurance_short_code');
$schema->getTable('health_insurance')->dropIndex('uniq_health_insurance_export_id');
}
}