<?php

declare(strict_types=1);

namespace CpCreation\VitiCore\Bridge\Doctrine\Migrations;

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

final class Version20260327151000 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Add promo recipient user/email targeting';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('ALTER TABLE cart_promo ADD assigned_user_id UUID DEFAULT NULL');
        $this->addSql('ALTER TABLE cart_promo ADD notification_email VARCHAR(255) DEFAULT NULL');
        $this->addSql('COMMENT ON COLUMN cart_promo.assigned_user_id IS \'(DC2Type:uuid)\'');
        $this->addSql('CREATE INDEX IDX_EFF9F7F3FBD687C3 ON cart_promo (assigned_user_id)');
        $this->addSql('ALTER TABLE cart_promo ADD CONSTRAINT FK_EFF9F7F3FBD687C3 FOREIGN KEY (assigned_user_id) REFERENCES user_user (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
    }

    public function down(Schema $schema): void
    {
        $this->addSql('ALTER TABLE cart_promo DROP CONSTRAINT FK_EFF9F7F3FBD687C3');
        $this->addSql('DROP INDEX IDX_EFF9F7F3FBD687C3');
        $this->addSql('ALTER TABLE cart_promo DROP assigned_user_id');
        $this->addSql('ALTER TABLE cart_promo DROP notification_email');
    }
}
