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