<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
final class Version20260316095211 extends AbstractMigration implements ContainerAwareInterface
{
use ContainerAwareTrait;
public function getDescription(): string
{
return 'Sync SKU with External ID for KROUSTY franchise (Prod only).';
}
public function up(Schema $schema): void
{
$env = $this->container->get('kernel')->getEnvironment();
if ($env === 'prod') {
$this->addSql("
UPDATE product p
INNER JOIN shop s ON p.shop_id = s.id
INNER JOIN franchise f ON s.franchise_id = f.id
SET p.sku = p.external_id
WHERE f.name LIKE '%KROUSTY%'
AND p.external_id IS NOT NULL
AND p.external_id <> ''
");
} else {
$this->write("Skipping SKU sync: Environment is '$env' (not 'prod').");
}
}
}