migrations/Version20250408011726.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 Version20250408011726 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'disable product categories of disabled product & category';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->addSql('
  15.             UPDATE product_category pc
  16.             SET pc.enabled = false
  17.             WHERE pc.product_id IN (
  18.                 SELECT p.id
  19.                 FROM product p
  20.                 WHERE p.enabled = false
  21.             )
  22.             AND pc.enabled = true
  23.         ');
  24.         $this->addSql('
  25.             UPDATE product_category pc
  26.             SET pc.enabled = false
  27.             WHERE pc.category_id IN (
  28.                 SELECT c.id
  29.                 FROM category c
  30.                 WHERE c.enabled = false
  31.             )
  32.             AND pc.enabled = true
  33.         ');
  34.     }
  35. }