30 lines
1.0 KiB
PHP
30 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
final class Version20260811120000 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Add task scheduling and recurrence fields.';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$this->addSql('ALTER TABLE task ADD scheduled_for DATE DEFAULT NULL, ADD recurrence_interval INT DEFAULT NULL, ADD recurrence_unit VARCHAR(10) DEFAULT NULL');
|
|
$this->addSql("UPDATE task SET recurrence_interval = 1, recurrence_unit = 'day' WHERE is_recurring = 1 AND (recurrence_interval IS NULL OR recurrence_unit IS NULL)");
|
|
$this->addSql('UPDATE task SET scheduled_for = DATE(created_at) WHERE scheduled_for IS NULL');
|
|
$this->addSql('ALTER TABLE task MODIFY scheduled_for DATE NOT NULL');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
$this->addSql('ALTER TABLE task DROP scheduled_for, DROP recurrence_interval, DROP recurrence_unit');
|
|
}
|
|
}
|