migrations/Version20230329122000.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 Version20230329122000 extends AbstractMigration
  8. {
  9.     public function getDescription(): string
  10.     {
  11.         return 'Add vendor_document_model_name field to the predefined_template table';
  12.     }
  13.     public function up(Schema $schema): void
  14.     {
  15.         $this->skipIf(
  16.             true === $schema->getTable('predefined_template')->hasColumn('vendor_document_model_name'),
  17.             'The vendor_document_model_name field already exists in the predefined_template table!'
  18.         );
  19.         $schema->getTable('predefined_template')
  20.             ->addColumn('vendor_document_model_name'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('predefined_template')->hasColumn('vendor_document_model_name'),
  29.             'The vendor_document_model_name is already removed from the predefined_template table!'
  30.         );
  31.         $schema->getTable('predefined_template')
  32.             ->dropColumn('vendor_document_model_name');
  33.     }
  34. }