migrations/Version20251120135541.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. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20251120135541 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'Agrega foreign key con ON DELETE CASCADE en tipo_destacado.categoria_id';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // Agregar foreign key con ON DELETE CASCADE
  18.         $this->addSql('ALTER TABLE tipo_destacado 
  19.             ADD CONSTRAINT FK_TIPO_DESTACADO_CATEGORIA 
  20.             FOREIGN KEY (categoria_id) 
  21.             REFERENCES categoria (id) 
  22.             ON DELETE CASCADE');
  23.     }
  24.     public function down(Schema $schema): void
  25.     {
  26.         // Eliminar foreign key
  27.         $this->addSql('ALTER TABLE tipo_destacado 
  28.             DROP FOREIGN KEY FK_TIPO_DESTACADO_CATEGORIA');
  29.     }
  30. }