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