<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20240625171500 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add employee_id to cmcm request';
}
public function up(Schema $schema): void
{
$this->skipIf($schema->getTable('cmcm_request')->hasColumn('employee_id'), 'Table cmcm_request already have employee_id column');
$table = $schema->getTable('cmcm_request');
$table->addColumn('employee_id', Types::STRING, ['length' => 255])->setNotnull(false);
$table->addForeignKeyConstraint('employee', ['employee_id'], ['id'], [], 'fk_employee_id');
}
public function down(Schema $schema): void
{
$this->skipIf(!$schema->getTable('cmcm_request')->hasColumn('employee_id'), 'Table cmcm_request does not have employee_id column');
$schema->getTable('cmcm_request')->dropColumn('employee_id');
}
}