<?php

declare(strict_types=1);

namespace CpCreation\VitiCore\Bridge\Doctrine\Migrations;

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

final class Version20260413154500 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Ajoute les options d’activation des événements fixes Google Analytics par page.';
    }

    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 enable_checkout_event_tracking BOOLEAN DEFAULT FALSE NOT NULL');
        $this->addSql('ALTER TABLE shop_shop_config ADD enable_payment_success_event_tracking BOOLEAN DEFAULT FALSE NOT NULL');
        $this->addSql('ALTER TABLE shop_shop_config ADD enable_payment_error_event_tracking BOOLEAN DEFAULT FALSE NOT NULL');
        $this->addSql('ALTER TABLE shop_shop_config ADD enable_payment_canceled_event_tracking BOOLEAN DEFAULT FALSE NOT NULL');
        $this->addSql('ALTER TABLE shop_shop_config ADD enable_contact_page_event_tracking BOOLEAN DEFAULT FALSE NOT NULL');
        $this->addSql('ALTER TABLE shop_shop_config ADD enable_contact_success_event_tracking BOOLEAN DEFAULT FALSE NOT 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 enable_checkout_event_tracking');
        $this->addSql('ALTER TABLE shop_shop_config DROP enable_payment_success_event_tracking');
        $this->addSql('ALTER TABLE shop_shop_config DROP enable_payment_error_event_tracking');
        $this->addSql('ALTER TABLE shop_shop_config DROP enable_payment_canceled_event_tracking');
        $this->addSql('ALTER TABLE shop_shop_config DROP enable_contact_page_event_tracking');
        $this->addSql('ALTER TABLE shop_shop_config DROP enable_contact_success_event_tracking');
    }
}
