<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20250509095100 extends AbstractMigration
{
public function getDescription(): string
{
return 'Increase inquiry.ged_id column length to 50';
}
public function up(Schema $schema): void
{
$this->skipIf(
!$schema->hasTable('inquiry')
|| 50 === $schema->getTable('inquiry')->getColumn('ged_id')->getLength(),
'Table inquiry does not exist or ged_id column length is already 50'
);
// Change column length from 15 to 50
$table = $schema->getTable('inquiry');
$table->getColumn('ged_id')->setLength(50);
}
public function down(Schema $schema): void
{
$this->skipIf(
!$schema->hasTable('inquiry')
|| 15 === $schema->getTable('inquiry')->getColumn('ged_id')->getLength(),
'Table inquiry does not exist or ged_id column length is already 15'
);
// Revert column length back to 15
$table = $schema->getTable('inquiry');
$table->getColumn('ged_id')->setLength(15);
}
}