<?php

declare(strict_types=1);

namespace CpCreation\VitiCore\Bridge\Doctrine\Migrations;

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

final class Version20260413131500 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Ajoute des snippets de tracking conditionnels pour checkout, confirmation paiement et contact.';
    }

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

        $this->addSql('ALTER TABLE shop_shop_config ADD tracking_checkout_scripts TEXT DEFAULT NULL');
        $this->addSql('ALTER TABLE shop_shop_config ADD tracking_payment_confirmation_scripts TEXT DEFAULT NULL');
        $this->addSql('ALTER TABLE shop_shop_config ADD tracking_contact_scripts TEXT DEFAULT NULL');
    }

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

        $this->addSql('ALTER TABLE shop_shop_config DROP tracking_checkout_scripts');
        $this->addSql('ALTER TABLE shop_shop_config DROP tracking_payment_confirmation_scripts');
        $this->addSql('ALTER TABLE shop_shop_config DROP tracking_contact_scripts');
    }
}
