<?php

declare(strict_types=1);

namespace CpCreation\VitiCore\Bridge\Doctrine\Migrations;

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

final class Version20260326103000 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Allow deleting product second images by setting product_product.second_image_id to NULL';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('ALTER TABLE product_product DROP CONSTRAINT FK_2931F1DEB17A08');
        $this->addSql('ALTER TABLE product_product ADD CONSTRAINT FK_2931F1DEB17A08 FOREIGN KEY (second_image_id) REFERENCES media_media (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
    }

    public function down(Schema $schema): void
    {
        $this->addSql('ALTER TABLE product_product DROP CONSTRAINT FK_2931F1DEB17A08');
        $this->addSql('ALTER TABLE product_product ADD CONSTRAINT FK_2931F1DEB17A08 FOREIGN KEY (second_image_id) REFERENCES media_media (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
    }
}
