<?php

declare(strict_types=1);

/*
 * Chill is a software for social workers
 *
 * For the full copyright and license information, please view
 * the LICENSE file that was distributed with this source code.
 */

namespace Chill\Migrations\Main;

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

final class Version20250313165611 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Associate an export generation with eventual saved export';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('ALTER TABLE chill_main_export_generation ADD savedExport_id UUID DEFAULT NULL');
        $this->addSql('COMMENT ON COLUMN chill_main_export_generation.savedExport_id IS \'(DC2Type:uuid)\'');
        $this->addSql('ALTER TABLE chill_main_export_generation ADD CONSTRAINT FK_E644B77DA61D6F69 FOREIGN KEY (savedExport_id) REFERENCES chill_main_saved_export (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('CREATE INDEX IDX_E644B77DA61D6F69 ON chill_main_export_generation (savedExport_id)');
    }

    public function down(Schema $schema): void
    {
        $this->addSql('ALTER TABLE chill_main_export_generation DROP CONSTRAINT FK_E644B77DA61D6F69');
        $this->addSql('DROP INDEX IDX_E644B77DA61D6F69');
        $this->addSql('ALTER TABLE chill_main_export_generation DROP savedExport_id');
    }
}
