migrations/Version20220914134445.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 Version20220914134445 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('message')->hasColumn('renderable_content'),
  17.             'The renderable_content field was already added in the message table!'
  18.         );
  19.         $schema->getTable('message')->addColumn(
  20.             'renderable_content',
  21.             Types::TEXT,
  22.             [
  23.                 'notnull' => false,
  24.                 'default' => 'null',
  25.             ]
  26.         );
  27.     }
  28.     public function down(Schema $schema): void
  29.     {
  30.         $this->skipIf(
  31.             false === $schema->getTable('message')->hasColumn('renderable_content'),
  32.             'The renderable_content field was already removed from the message table!'
  33.         );
  34.         $schema->getTable('message')->dropColumn('renderable_content');
  35.     }
  36. }