<?php

/*
 * This file is part of the VITICORE2 package.
 *
 * (c) CP Creation <web@cpcreation.fr>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CpCreation\VitiCore\Bridge\Doctrine\Migrations;

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

final class Version20260724102000 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Aligne les types temporels de l’emailing avec les métadonnées Doctrine.';
    }

    public function up(Schema $schema): void
    {
        $this->abortIf(!$this->connection->getDatabasePlatform() instanceof PostgreSQLPlatform, 'Cette migration nécessite PostgreSQL.');

        $this->addSql('COMMENT ON COLUMN marketing_brevo_configuration.last_checked_at IS \'(DC2Type:datetimetz_immutable)\'');
        $this->addSql('COMMENT ON COLUMN marketing_brevo_configuration.created_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('COMMENT ON COLUMN marketing_brevo_configuration.updated_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('COMMENT ON COLUMN marketing_email_campaign.sent_at IS \'(DC2Type:datetimetz_immutable)\'');
        $this->addSql('COMMENT ON COLUMN marketing_email_campaign.created_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('COMMENT ON COLUMN marketing_email_campaign.updated_at IS \'(DC2Type:datetime_immutable)\'');
    }

    public function down(Schema $schema): void
    {
        $this->abortIf(!$this->connection->getDatabasePlatform() instanceof PostgreSQLPlatform, 'Cette migration nécessite PostgreSQL.');

        $this->addSql('COMMENT ON COLUMN marketing_brevo_configuration.last_checked_at IS NULL');
        $this->addSql('COMMENT ON COLUMN marketing_brevo_configuration.created_at IS NULL');
        $this->addSql('COMMENT ON COLUMN marketing_brevo_configuration.updated_at IS NULL');
        $this->addSql('COMMENT ON COLUMN marketing_email_campaign.sent_at IS NULL');
        $this->addSql('COMMENT ON COLUMN marketing_email_campaign.created_at IS NULL');
        $this->addSql('COMMENT ON COLUMN marketing_email_campaign.updated_at IS NULL');
    }
}
