<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20240625155500 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add dossier_type_id to cmcm request';
}
public function up(Schema $schema): void
{
$this->skipIf($schema->getTable('cmcm_request')->hasColumn('dossier_type_id'), 'Table cmcm_request already have dossier_type_id column');
$table = $schema->getTable('cmcm_request');
$table->addColumn('dossier_type_id', Types::STRING, ['length' => 255])->setNotnull(false);
$table->addForeignKeyConstraint('dossier_type', ['dossier_type_id'], ['id'], [], 'fk_dossier_type_id');
}
public function down(Schema $schema): void
{
$this->skipIf(!$schema->getTable('cmcm_request')->hasColumn('dossier_type_id'), 'Table cmcm_request does not have dossier_type_id column');
$schema->getTable('cmcm_request')->dropColumn('dossier_type_id');
}
}