<?php

declare(strict_types=1);

namespace DoctrineMigrations;

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

final class Version20260321260000 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Make firstName, lastName, email nullable on billet_buyer for guest orders';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('ALTER TABLE billet_buyer ALTER COLUMN first_name DROP NOT NULL');
        $this->addSql('ALTER TABLE billet_buyer ALTER COLUMN last_name DROP NOT NULL');
        $this->addSql('ALTER TABLE billet_buyer ALTER COLUMN email DROP NOT NULL');
    }

    public function down(Schema $schema): void
    {
        $this->addSql("UPDATE billet_buyer SET first_name = '' WHERE first_name IS NULL");
        $this->addSql("UPDATE billet_buyer SET last_name = '' WHERE last_name IS NULL");
        $this->addSql("UPDATE billet_buyer SET email = '' WHERE email IS NULL");
        $this->addSql('ALTER TABLE billet_buyer ALTER COLUMN first_name SET NOT NULL');
        $this->addSql('ALTER TABLE billet_buyer ALTER COLUMN last_name SET NOT NULL');
        $this->addSql('ALTER TABLE billet_buyer ALTER COLUMN email SET NOT NULL');
    }
}
