migrations/Version20251209140000.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\DBAL\Types\Types;
  6. use Doctrine\Migrations\AbstractMigration;
  7. final class Version20251209140000 extends AbstractMigration
  8. {
  9.     public function getDescription(): string
  10.     {
  11.         return 'Add sort_order field to mycmcm_request_category table';
  12.     }
  13.     public function up(Schema $schema): void
  14.     {
  15.         $table $schema->getTable('mycmcm_request_category');
  16.         $this->skipIf(
  17.             $table->hasColumn('sort_order'),
  18.             'The sort_order column already exists in the mycmcm_request_category table'
  19.         );
  20.         $table->addColumn('sort_order'Types::INTEGER)
  21.             ->setNotnull(true)
  22.             ->setDefault(0);
  23.     }
  24.     public function down(Schema $schema): void
  25.     {
  26.         $table $schema->getTable('mycmcm_request_category');
  27.         $this->skipIf(
  28.             !$table->hasColumn('sort_order'),
  29.             'The sort_order column does not exist in the mycmcm_request_category table'
  30.         );
  31.         $table->dropColumn('sort_order');
  32.     }
  33. }