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