migrations/Version20230719085301.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 Version20230719085301 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Add is_form_complete field for the member_application table';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->skipIf(
  15.             true === $schema->getTable('member_application')->hasColumn('is_form_complete'),
  16.             'The is_form_complete field already set in the member_application table!'
  17.         );
  18.         $schema->getTable('member_application')
  19.             ->addColumn('is_form_complete''boolean', ['notnull' => true'default' => true]);
  20.     }
  21.     public function postUp(Schema $schema): void
  22.     {
  23.         $this->connection->executeQuery(
  24.             'UPDATE member_application set is_form_complete=1'
  25.         );
  26.     }
  27.     public function down(Schema $schema): void
  28.     {
  29.         $this->skipIf(
  30.             false === $schema->getTable('member_application')->hasColumn('is_form_complete'),
  31.             'The is_form_complete is already removed from the member_application table!'
  32.         );
  33.         $schema->getTable('member_application')->dropColumn('is_form_complete');
  34.     }
  35. }