<?php

declare(strict_types=1);

namespace CpCreation\VitiCore\Bridge\Doctrine\Migrations;

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

final class Version20260413120000 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Ajoute la configuration de trackers marketing et analytics sur shop_shop_config.';
    }

    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 google_tag_manager_id VARCHAR(64) DEFAULT NULL');
        $this->addSql('ALTER TABLE shop_shop_config ADD google_analytics_ids JSON DEFAULT NULL');
        $this->addSql('ALTER TABLE shop_shop_config ADD facebook_pixel_ids JSON DEFAULT NULL');
        $this->addSql('ALTER TABLE shop_shop_config ADD tracking_head_scripts TEXT DEFAULT NULL');
        $this->addSql('ALTER TABLE shop_shop_config ADD tracking_body_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 google_tag_manager_id');
        $this->addSql('ALTER TABLE shop_shop_config DROP google_analytics_ids');
        $this->addSql('ALTER TABLE shop_shop_config DROP facebook_pixel_ids');
        $this->addSql('ALTER TABLE shop_shop_config DROP tracking_head_scripts');
        $this->addSql('ALTER TABLE shop_shop_config DROP tracking_body_scripts');
    }
}
