migrations/Version20221222113505.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 Version20221222113505 extends AbstractMigration
  8. {
  9.     public function getDescription(): string
  10.     {
  11.         return 'Add automaticMemberApplicationAccept to companies';
  12.     }
  13.     public function up(Schema $schema): void
  14.     {
  15.         $this->skipIf(
  16.             true === $schema->getTable('health_insurance')->hasColumn('short_code'),
  17.             'The short_code field already exists in the health_insurance table!'
  18.         );
  19.         $schema->getTable('health_insurance')
  20.             ->addColumn('short_code'Types::STRING)
  21.             ->setNotnull(false);
  22.         $schema->getTable('health_insurance')
  23.             ->addColumn('export_id'Types::STRING)
  24.             ->setNotnull(false);
  25.     }
  26.     public function postUp(Schema $schema): void
  27.     {
  28.         $this->connection->executeQuery(
  29.             'UPDATE health_insurance set short_code=id'
  30.         );
  31.         $this->connection->executeQuery(
  32.             'UPDATE health_insurance set export_id=id'
  33.         );
  34.     }
  35.     public function down(Schema $schema): void
  36.     {
  37.         $this->skipIf(
  38.             false === $schema->getTable('health_insurance')->hasColumn('short_code'),
  39.             'The short_code is already removed from the health_insurance table!'
  40.         );
  41.         $schema->getTable('health_insurance')
  42.             ->dropColumn('short_code')
  43.             ->dropColumn('export_id');
  44.     }
  45. }