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