migrations/Version20260414100000.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\Migrations\AbstractMigration;
  6. final class Version20260414100000 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Asegura que existen los estados Cancelada y Rechazada en estado_solicitud';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->addSql("INSERT INTO estado_solicitud (nombre)
  15.             SELECT 'Cancelada' FROM DUAL
  16.             WHERE NOT EXISTS (
  17.                 SELECT 1 FROM estado_solicitud WHERE LOWER(nombre) = 'cancelada'
  18.             )");
  19.         $this->addSql("INSERT INTO estado_solicitud (nombre)
  20.             SELECT 'Rechazada' FROM DUAL
  21.             WHERE NOT EXISTS (
  22.                 SELECT 1 FROM estado_solicitud WHERE LOWER(nombre) = 'rechazada'
  23.             )");
  24.     }
  25.     public function down(Schema $schema): void
  26.     {
  27.         // No eliminamos datos en el down para no romper referencias existentes
  28.     }
  29. }