first version of defer/sick mode

This commit is contained in:
Joren de Graaf
2026-09-07 17:50:09 +02:00
parent 39130cce8d
commit b129794b06
12 changed files with 338 additions and 70 deletions
+43
View File
@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260907123000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add an optional self-referencing parent task relationship for sub-tasks.';
}
public function up(Schema $schema): void
{
if ($this->connection->getDatabasePlatform() instanceof PostgreSQLPlatform) {
$this->addSql('ALTER TABLE task ADD parent_task_id INT DEFAULT NULL');
$this->addSql('CREATE INDEX IDX_TASK_PARENT_TASK ON task (parent_task_id)');
$this->addSql('ALTER TABLE task ADD CONSTRAINT FK_TASK_PARENT_TASK FOREIGN KEY (parent_task_id) REFERENCES task (id) ON DELETE SET NULL');
return;
}
$this->addSql('ALTER TABLE task ADD parent_task_id INT DEFAULT NULL, ADD INDEX IDX_TASK_PARENT_TASK (parent_task_id), ADD CONSTRAINT FK_TASK_PARENT_TASK FOREIGN KEY (parent_task_id) REFERENCES task (id) ON DELETE SET NULL');
}
public function down(Schema $schema): void
{
if ($this->connection->getDatabasePlatform() instanceof PostgreSQLPlatform) {
$this->addSql('ALTER TABLE task DROP CONSTRAINT FK_TASK_PARENT_TASK');
$this->addSql('DROP INDEX IDX_TASK_PARENT_TASK');
$this->addSql('ALTER TABLE task DROP parent_task_id');
return;
}
$this->addSql('ALTER TABLE task DROP FOREIGN KEY FK_TASK_PARENT_TASK, DROP INDEX IDX_TASK_PARENT_TASK, DROP parent_task_id');
}
}