migrations/Version20240506131600.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 Version20240506131600 extends AbstractMigration
  8. {
  9.     public function getDescription(): string
  10.     {
  11.         return '';
  12.     }
  13.     public function up(Schema $schema): void
  14.     {
  15.         $this->skipIf(
  16.             true === $schema->getTable('cmcm_request')->hasColumn('document_ids'),
  17.             'The document_ids field was already added in the cmcm_request table!'
  18.         );
  19.         $schema->getTable('cmcm_request')->addColumn(
  20.             'document_ids',
  21.             Types::JSON,
  22.             [
  23.                 'notnull' => true,
  24.                 'default' => '{}',
  25.             ]
  26.         );
  27.         $schema->getTable('cmcm_request')->dropColumn('document_id');
  28.     }
  29.     public function down(Schema $schema): void
  30.     {
  31.         $this->skipIf(
  32.             false === $schema->getTable('cmcm_request')->hasColumn('document_ids'),
  33.             'The document_ids field was already removed from the cmcm_request table!'
  34.         );
  35.         $schema->getTable('cmcm_request')->dropColumn('document_ids');
  36.         $schema->getTable('cmcm_request')->addColumn(
  37.             'document_id',
  38.             Types::STRING,
  39.             [
  40.                 'length' => 255,
  41.                 'notnull' => false,
  42.                 'default' => null,
  43.             ]
  44.         );
  45.     }
  46. }