<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20240111170500 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add assigned employee to member application.';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->getTable('member_application')->hasColumn('assigned_employee_id'),
'The assigned_employee_id column was already added to assigned_employee_id table!'
);
$memberApplicationTable = $schema->getTable('member_application');
$memberApplicationTable->addColumn('assigned_employee_id', Types::STRING, ['length' => 255])->setNotnull(false);
$memberApplicationTable->addIndex(['assigned_employee_id'], 'idx_member_application_assigned_employee_id');
$memberApplicationTable->addForeignKeyConstraint(
$schema->getTable('employee'),
['assigned_employee_id'],
['id'],
[],
'fk_member_application_employee'
);
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->getTable('member_application')->hasColumn('assigned_employee_id'),
'The assigned_employee_id column was already removed to member_application table!'
);
$memberApplicationTable = $schema->getTable('member_application');
$memberApplicationTable->dropIndex('idx_member_application_assigned_employee_id');
$memberApplicationTable->dropColumn('assigned_employee_id');
}
}