<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20251006085017 extends AbstractMigration
{
public function getDescription(): string
{
return 'Updates all product_category records that are still marked as enabled = true while their parent product is disabled (enabled = false)';
}
public function up(Schema $schema): void
{
$this->addSql('UPDATE product_category pc
JOIN product p ON pc.product_id = p.id
SET
pc.enabled = FALSE,
pc.disabled_at = p.disabled_at
WHERE p.enabled = FALSE
AND pc.enabled = TRUE
AND pc.deleted_at IS NULL');
}
}