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