<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20261115135143 extends AbstractMigration
{
public function getDescription(): string
{
return 'Soft delete product categories linked to soft deleted categories or products, and promotional offers linked to soft deleted categories';
}
public function up(Schema $schema): void
{
$this->addSql('UPDATE product_category pc INNER JOIN category c ON c.id = pc.category_id SET pc.deleted = 1, pc.deleted_at = c.deleted_at WHERE pc.deleted_at IS NULL AND c.deleted_at IS NOT NULL');
$this->addSql('UPDATE product_category pc INNER JOIN product p ON p.id = pc.product_id SET pc.deleted = 1, pc.deleted_at = p.deleted_at WHERE pc.deleted_at IS NULL AND p.deleted_at IS NOT NULL');
$this->addSql('UPDATE promotional_offer po INNER JOIN category c ON c.id = po.category_id SET po.deleted = 1, po.deleted_at = c.deleted_at WHERE po.deleted_at IS NULL AND c.deleted_at IS NOT NULL');
}
}