<?php

declare(strict_types=1);

namespace CpCreation\VitiCore\Bridge\Doctrine\Migrations;

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

final class Version20260603124000 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Synchronise les index panier et le type Doctrine de cart checkout initiated_at.';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('CREATE INDEX IF NOT EXISTS cart_cart_last_activity_at_idx ON cart_cart (last_activity_at)');
        $this->addSql('CREATE INDEX IF NOT EXISTS cart_cart_abandoned_at_idx ON cart_cart (abandoned_at)');
        $this->addSql('ALTER TABLE cart_cart_checkout ALTER initiated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE');
        $this->addSql('COMMENT ON COLUMN cart_cart_checkout.initiated_at IS \'(DC2Type:datetime_immutable)\'');
    }

    public function down(Schema $schema): void
    {
        $this->addSql('COMMENT ON COLUMN cart_cart_checkout.initiated_at IS NULL');
    }
}
