<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20230605095700 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add sport_federation_id field for the member_application table';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->getTable('member_application')->hasColumn('sport_federation_id'),
'The sport_federation_id field already set in the member_application table!'
);
$memberApplicationTable = $schema->getTable('member_application');
$memberApplicationTable->addColumn('sport_federation_id', Types::STRING, ['length' => 255, 'notnull' => false]);
$memberApplicationTable->addIndex(['sport_federation_id'], 'member_application_sport_federation_idx');
$memberApplicationTable->addColumn('sport_license_number', Types::STRING, ['length' => 255, 'notnull' => false]);
$memberApplicationTable = $schema->getTable('member_application_original_data');
$memberApplicationTable->addColumn('sport_federation_id', Types::STRING, ['length' => 255, 'notnull' => false]);
$memberApplicationTable->addIndex(['sport_federation_id'], 'member_application_original_data_sport_federation_idx');
$memberApplicationTable->addColumn('sport_license_number', Types::STRING, ['length' => 255, 'notnull' => false]);
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->getTable('member_application')->hasColumn('sport_federation_id'),
'The sport_federation_id is already removed from the member_application table!'
);
$schema->getTable('member_application')->dropIndex('member_application_sport_federation_idx');
$schema->getTable('member_application')->dropColumn('sport_federation_id');
$schema->getTable('member_application')->dropColumn('sport_license_number');
$schema->getTable('member_application_original_data')->dropIndex('member_application_original_data_sport_federation_idx');
$schema->getTable('member_application_original_data')->dropColumn('sport_federation_id');
$schema->getTable('member_application_original_data')->dropColumn('sport_license_number');
}
}