<?php

declare(strict_types=1);

namespace CpCreation\VitiCore\Bridge\Doctrine\Migrations;

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

final class Version20260327231500 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Ajoute une couleur et une icône aux catégories de dépôts.';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('ALTER TABLE depot_category ADD color VARCHAR(7) DEFAULT NULL');
        $this->addSql('ALTER TABLE depot_category ADD image_id UUID DEFAULT NULL');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_DEPOT_CATEGORY_IMAGE ON depot_category (image_id)');
        $this->addSql('ALTER TABLE depot_category ADD CONSTRAINT FK_DEPOT_CATEGORY_IMAGE FOREIGN KEY (image_id) REFERENCES media_media (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
    }

    public function down(Schema $schema): void
    {
        $this->addSql('ALTER TABLE depot_category DROP CONSTRAINT FK_DEPOT_CATEGORY_IMAGE');
        $this->addSql('DROP INDEX UNIQ_DEPOT_CATEGORY_IMAGE');
        $this->addSql('ALTER TABLE depot_category DROP image_id');
        $this->addSql('ALTER TABLE depot_category DROP color');
    }
}
