migrations/Version20221020125649.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 Version20221020125649 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Make dossier_id field nullable in member_application table';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->skipIf(
  15.             false === $schema->getTable('member_application')->getColumn('dossier_id')->getNotnull(),
  16.             'The dossier_id field in the member_application table is already nullable!'
  17.         );
  18.         $schema->getTable('member_application')
  19.             ->getColumn('dossier_id')->setNotnull(false);
  20.     }
  21.     public function down(Schema $schema): void
  22.     {
  23.         $this->skipIf(
  24.             true === $schema->getTable('member_application')->getColumn('dossier_id')->getNotnull(),
  25.             'The dossier_id field in the member_application table is already not nullable!'
  26.         );
  27.         $schema->getTable('member_application')
  28.             ->getColumn('dossier_id')->setNotnull(true);
  29.     }
  30. }