migrations/Version20240704103300.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 Version20240704103300 extends AbstractMigration
  8. {
  9.     public function getDescription(): string
  10.     {
  11.         return 'Add total page count to cmcm request';
  12.     }
  13.     public function up(Schema $schema): void
  14.     {
  15.         $this->skipIf(
  16.             true === $schema->getTable('cmcm_request')->hasColumn('total_page_count'),
  17.             'The total_page_count field already exists in the cmcm_request table!'
  18.         );
  19.         $schema->getTable('cmcm_request')
  20.             ->addColumn('total_page_count'Types::INTEGER)->setNotnull(true)->setDefault(0);
  21.     }
  22.     public function down(Schema $schema): void
  23.     {
  24.         $this->skipIf(
  25.             false === $schema->getTable('cmcm_request')->hasColumn('total_page_count'),
  26.             'The total_page_count is already removed from the cmcm_request table!'
  27.         );
  28.         $schema->getTable('cmcm_request')
  29.             ->dropColumn('total_page_count');
  30.     }
  31. }