<?php

declare(strict_types=1);

namespace CpCreation\VitiCore\Bridge\Doctrine\Migrations;

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

final class Version20260413170000 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Supprime l’unicité SQL sur cart_promo.title pour autoriser les doublons entre promos auto.';
    }

    public function up(Schema $schema): void
    {
        $this->abortIf(
            'postgresql' !== $this->connection->getDatabasePlatform()->getName(),
            'Cette migration ne supporte que PostgreSQL.'
        );

        $this->addSql('DROP INDEX IF EXISTS UNIQ_EFF9F7F32B36786B');
    }

    public function down(Schema $schema): void
    {
        $this->abortIf(
            'postgresql' !== $this->connection->getDatabasePlatform()->getName(),
            'Cette migration ne supporte que PostgreSQL.'
        );

        $this->addSql('CREATE UNIQUE INDEX IF NOT EXISTS UNIQ_EFF9F7F32B36786B ON cart_promo (title)');
    }
}
