migrations/Version20221103111400.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 Version20221103111400 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return '';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->skipIf(
  15.             false === $schema->getTable('tariff')->getColumn('available_from')->getNotnull(),
  16.             'The available_from column is already nullable in tariff table!'
  17.         );
  18.         $schema->getTable('tariff')
  19.             ->getColumn('available_from')
  20.             ->setNotnull(false);
  21.         $schema->getTable('tariff')
  22.             ->getColumn('available_to')
  23.             ->setNotnull(false);
  24.     }
  25.     public function down(Schema $schema): void
  26.     {
  27.         $this->skipIf(
  28.             true === $schema->getTable('tariff')->getColumn('available_from')->getNotnull(),
  29.             'The available_from column is already nullable in tariff table!'
  30.         );
  31.         $schema->getTable('tariff')
  32.             ->getColumn('available_from')
  33.             ->setNotnull(true);
  34.         $schema->getTable('tariff')
  35.             ->getColumn('available_to')
  36.             ->setNotnull(true);
  37.     }
  38. }