<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260221120000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add source_task_id self-referencing FK on task table for duplication tracking';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE task ADD source_task_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE task ADD CONSTRAINT FK_527EDB25E55437C0 FOREIGN KEY (source_task_id) REFERENCES task (id) ON DELETE SET NULL');
$this->addSql('CREATE INDEX IDX_527EDB25E55437C0 ON task (source_task_id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE task DROP FOREIGN KEY FK_527EDB25E55437C0');
$this->addSql('DROP INDEX IDX_527EDB25E55437C0 ON task');
$this->addSql('ALTER TABLE task DROP source_task_id');
}
}