migrations/Version20251006085017.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 Version20251006085017 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Updates all product_category records that are still marked as enabled = true while their parent product is disabled (enabled = false)';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->addSql('UPDATE product_category pc
  15.         JOIN product p ON pc.product_id = p.id
  16.         SET
  17.             pc.enabled = FALSE,
  18.             pc.disabled_at = p.disabled_at
  19.         WHERE p.enabled = FALSE
  20.         AND pc.enabled = TRUE
  21.         AND pc.deleted_at IS NULL');
  22.     }
  23. }