migrations/Version20251118164904.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 Version20251118164904 extends AbstractMigration
  8. {
  9.     public function getDescription(): string
  10.     {
  11.         return 'Add dossier_type_id and department_id to mycmcm_request_category table';
  12.     }
  13.     public function up(Schema $schema): void
  14.     {
  15.         $this->skipIf(
  16.             true === $schema->getTable('mycmcm_request_category')->hasColumn('dossier_type_id'),
  17.             'The dossier_type_id column already exists in mycmcm_request_category table!'
  18.         );
  19.         $table $schema->getTable('mycmcm_request_category');
  20.         $table->addColumn('dossier_type_id'Types::GUID)->setNotnull(false);
  21.         $table->addColumn('department_id'Types::GUID)->setNotnull(false);
  22.         $table->addForeignKeyConstraint(
  23.             'dossier_type',
  24.             ['dossier_type_id'],
  25.             ['id'],
  26.             ['onDelete' => 'SET NULL'],
  27.             'fk_mycmcm_request_category_dossier_type'
  28.         );
  29.         $table->addForeignKeyConstraint(
  30.             'department',
  31.             ['department_id'],
  32.             ['id'],
  33.             ['onDelete' => 'SET NULL'],
  34.             'fk_mycmcm_request_category_department'
  35.         );
  36.     }
  37.     public function down(Schema $schema): void
  38.     {
  39.         $table $schema->getTable('mycmcm_request_category');
  40.         $table->removeForeignKey('fk_mycmcm_request_category_dossier_type');
  41.         $table->removeForeignKey('fk_mycmcm_request_category_department');
  42.         $table->dropColumn('dossier_type_id');
  43.         $table->dropColumn('department_id');
  44.     }
  45. }