<?php

declare(strict_types=1);

namespace CpCreation\VitiCore\Bridge\Doctrine\Migrations;

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

final class Version20260327201000 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Add persisted cart document type for order or invoice flows';
    }

    public function up(Schema $schema): void
    {
        $this->addSql("ALTER TABLE cart_cart ADD document_type VARCHAR(32) DEFAULT 'order' NOT NULL");
        $this->addSql("UPDATE cart_cart SET document_type = 'invoice' WHERE invoice_id IS NOT NULL");
    }

    public function down(Schema $schema): void
    {
        $this->addSql('ALTER TABLE cart_cart DROP document_type');
    }
}
