<?php

declare(strict_types=1);

namespace CpCreation\VitiCore\Bridge\Doctrine\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20260612121600 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Ajoute les variants cibles aux codes promo.';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('CREATE TABLE promo_product_variant (promo_id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', product_variant_id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', INDEX IDX_542BF5CCD0C07AFF (promo_id), INDEX IDX_542BF5CCA80EF684 (product_variant_id), PRIMARY KEY(promo_id, product_variant_id)) DEFAULT CHARACTER SET UTF8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
        $this->addSql('ALTER TABLE promo_product_variant ADD CONSTRAINT FK_542BF5CCD0C07AFF FOREIGN KEY (promo_id) REFERENCES cart_promo (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE promo_product_variant ADD CONSTRAINT FK_542BF5CCA80EF684 FOREIGN KEY (product_variant_id) REFERENCES product_variant (id) ON DELETE CASCADE');
    }

    public function down(Schema $schema): void
    {
        $this->addSql('DROP TABLE promo_product_variant');
    }
}
