<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20251118164904 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add dossier_type_id and department_id to mycmcm_request_category table';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->getTable('mycmcm_request_category')->hasColumn('dossier_type_id'),
'The dossier_type_id column already exists in mycmcm_request_category table!'
);
$table = $schema->getTable('mycmcm_request_category');
$table->addColumn('dossier_type_id', Types::GUID)->setNotnull(false);
$table->addColumn('department_id', Types::GUID)->setNotnull(false);
$table->addForeignKeyConstraint(
'dossier_type',
['dossier_type_id'],
['id'],
['onDelete' => 'SET NULL'],
'fk_mycmcm_request_category_dossier_type'
);
$table->addForeignKeyConstraint(
'department',
['department_id'],
['id'],
['onDelete' => 'SET NULL'],
'fk_mycmcm_request_category_department'
);
}
public function down(Schema $schema): void
{
$table = $schema->getTable('mycmcm_request_category');
$table->removeForeignKey('fk_mycmcm_request_category_dossier_type');
$table->removeForeignKey('fk_mycmcm_request_category_department');
$table->dropColumn('dossier_type_id');
$table->dropColumn('department_id');
}
}