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