migrations/Version20250509095100.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. final class Version20250509095100 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Increase inquiry.ged_id column length to 50';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->skipIf(
  15.             !$schema->hasTable('inquiry')
  16.             || 50 === $schema->getTable('inquiry')->getColumn('ged_id')->getLength(),
  17.             'Table inquiry does not exist or ged_id column length is already 50'
  18.         );
  19.         // Change column length from 15 to 50
  20.         $table $schema->getTable('inquiry');
  21.         $table->getColumn('ged_id')->setLength(50);
  22.     }
  23.     public function down(Schema $schema): void
  24.     {
  25.         $this->skipIf(
  26.             !$schema->hasTable('inquiry')
  27.             || 15 === $schema->getTable('inquiry')->getColumn('ged_id')->getLength(),
  28.             'Table inquiry does not exist or ged_id column length is already 15'
  29.         );
  30.         // Revert column length back to 15
  31.         $table $schema->getTable('inquiry');
  32.         $table->getColumn('ged_id')->setLength(15);
  33.     }
  34. }