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