migrations/Version20221219161113.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 Version20221219161113 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Add automaticMemberApplicationAccept to companies - part 2';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->skipIf(
  15.             true === $schema->getTable('company')->getColumn('automatic_member_application_accept')->getNotnull(),
  16.             'The automatic_member_application_accept field already set to not null!'
  17.         );
  18.         $schema->getTable('company')
  19.             ->getColumn('automatic_member_application_accept')
  20.             ->setNotnull(true);
  21.     }
  22.     public function postUp(Schema $schema): void
  23.     {
  24.         $this->connection->executeQuery(
  25.             'UPDATE company set automatic_member_application_accept=0'
  26.         );
  27.     }
  28.     public function down(Schema $schema): void
  29.     {
  30.         $this->skipIf(
  31.             false === $schema->getTable('company')->hasColumn('automatic_member_application_accept'),
  32.             'The automatic_member_application_accept is already removed from the company table!'
  33.         );
  34.         $schema->getTable('company')
  35.             ->getColumn('automatic_member_application_accept')
  36.             ->setNotnull(false);
  37.     }
  38. }