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