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