migrations/Version20221222124001.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 Version20221222124001 extends AbstractMigration
  8. {
  9.     public function getDescription(): string
  10.     {
  11.         return 'Add bic to sepa_direct_debit_application';
  12.     }
  13.     public function up(Schema $schema): void
  14.     {
  15.         $this->skipIf(
  16.             true === $schema->getTable('sepa_direct_debit_application')->hasColumn('bic'),
  17.             'The bic field already exists in the sepa_direct_debit_application table!'
  18.         );
  19.         $schema->getTable('sepa_direct_debit_application')
  20.             ->addColumn('bic'Types::STRING)
  21.             ->setNotnull(false);
  22.     }
  23.     public function down(Schema $schema): void
  24.     {
  25.         $this->skipIf(
  26.             false === $schema->getTable('sepa_direct_debit_application')->hasColumn('bic'),
  27.             'The bic is already removed from the sepa_direct_debit_application table!'
  28.         );
  29.         $schema->getTable('sepa_direct_debit_application')
  30.             ->dropColumn('bic');
  31.     }
  32. }