Add migration for a new cancelled_at
column for scheduled tasks
[MAILPOET-5755]
This commit is contained in:
committed by
Ján Mikláš
parent
e55a861137
commit
1918d30fcd
@@ -20,6 +20,7 @@ use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||
class ScheduledTaskEntity {
|
||||
const STATUS_COMPLETED = 'completed';
|
||||
const STATUS_SCHEDULED = 'scheduled';
|
||||
const STATUS_CANCELLED = 'cancelled';
|
||||
const STATUS_PAUSED = 'paused';
|
||||
const STATUS_INVALID = 'invalid';
|
||||
const VIRTUAL_STATUS_RUNNING = 'running'; // For historical reasons this is stored as null in DB
|
||||
@@ -59,6 +60,12 @@ class ScheduledTaskEntity {
|
||||
*/
|
||||
private $scheduledAt;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetimetz", nullable=true)
|
||||
* @var DateTimeInterface|null
|
||||
*/
|
||||
private $cancelledAt;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetimetz", nullable=true)
|
||||
* @var DateTimeInterface|null
|
||||
@@ -155,6 +162,20 @@ class ScheduledTaskEntity {
|
||||
$this->scheduledAt = $scheduledAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTimeInterface|null
|
||||
*/
|
||||
public function getCancelledAt() {
|
||||
return $this->cancelledAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTimeInterface|null $cancelledAt
|
||||
*/
|
||||
public function setCancelledAt($cancelledAt) {
|
||||
$this->cancelledAt = $cancelledAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTimeInterface|null
|
||||
*/
|
||||
|
21
mailpoet/lib/Migrations/Db/Migration_20240617_122847_Db.php
Normal file
21
mailpoet/lib/Migrations/Db/Migration_20240617_122847_Db.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace MailPoet\Migrations\Db;
|
||||
|
||||
use MailPoet\Entities\ScheduledTaskEntity;
|
||||
use MailPoet\Migrator\DbMigration;
|
||||
|
||||
class Migration_20240617_122847_Db extends DbMigration {
|
||||
public function run(): void {
|
||||
$scheduledTasksTable = $this->getTableName(ScheduledTaskEntity::class);
|
||||
$newColumn = 'cancelled_at';
|
||||
if ($this->columnExists($scheduledTasksTable, $newColumn)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->connection->executeQuery(
|
||||
"ALTER TABLE `{$scheduledTasksTable}`
|
||||
ADD COLUMN `{$newColumn}` TIMESTAMP NULL DEFAULT NULL"
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user