<?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\Ticket;

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

final class Version20250924124214 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Add parent to motive';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('ALTER TABLE chill_ticket.motive ADD parent_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE chill_ticket.motive ADD CONSTRAINT FK_DE298BF8727ACA70 FOREIGN KEY (parent_id) REFERENCES chill_ticket.motive (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('CREATE INDEX IDX_DE298BF8727ACA70 ON chill_ticket.motive (parent_id)');
    }

    public function down(Schema $schema): void
    {
        $this->addSql('ALTER TABLE chill_ticket.motive DROP CONSTRAINT FK_DE298BF8727ACA70');
        $this->addSql('DROP INDEX chill_ticket.IDX_DE298BF8727ACA70');
        $this->addSql('ALTER TABLE chill_ticket.motive DROP parent_id');
    }
}
