<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version2025040490000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add department_phone to employee table';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->getTable('employee')->hasColumn('department_phone'),
'The department_phone field already exists in the employee table!'
);
$table = $schema->getTable('employee');
$table->addColumn('department_phone', Types::STRING, ['notnull' => false]);
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->getTable('employee')->hasColumn('department_phone'),
'The department_phone is already removed from the employee table!'
);
$table = $schema->getTable('employee');
$table->dropColumn('department_phone');
}
}