<?php 
 
declare(strict_types=1); 
 
namespace DoctrineMigrations; 
 
use Doctrine\DBAL\Schema\Schema; 
use Doctrine\DBAL\Types\Types; 
use Doctrine\Migrations\AbstractMigration; 
 
final class Version20230126141625 extends AbstractMigration 
{ 
    public function getDescription(): string 
    { 
        return 'Add subject to ticket'; 
    } 
 
    public function up(Schema $schema): void 
    { 
        $this->skipIf( 
            true === $schema->getTable('ticket')->hasColumn('subject'), 
            'The subject field already exists in the ticket table!' 
        ); 
 
        $schema->getTable('ticket') 
            ->addColumn('subject', Types::STRING, ['length' => 255]) 
            ->setNotnull(false); 
    } 
 
    public function down(Schema $schema): void 
    { 
        $this->skipIf( 
            false === $schema->getTable('ticket')->hasColumn('subject'), 
            'The subject is already removed from the ticket table!' 
        ); 
 
        $schema->getTable('ticket') 
            ->dropColumn('subject'); 
    } 
}