Improve compatibility with old DB versions that can't take current_timestamp() as a default value for DATETIME column

This commit is contained in:
Kijin Sung 2024-11-20 14:03:22 +09:00
parent 84e57ff876
commit d3b3dc7b0e
2 changed files with 3 additions and 3 deletions

View file

@ -93,8 +93,8 @@ class DB implements QueueInterface
public function addTask(string $handler, ?object $args = null, ?object $options = null): int
{
$oDB = RFDB::getInstance();
$stmt = $oDB->prepare('INSERT INTO task_queue (handler, args, options) VALUES (?, ?, ?)');
$result = $stmt->execute([$handler, serialize($args), serialize($options)]);
$stmt = $oDB->prepare('INSERT INTO task_queue (handler, args, options, regdate) VALUES (?, ?, ?, ?)');
$result = $stmt->execute([$handler, serialize($args), serialize($options), date('Y-m-d H:i:s')]);
return $result ? $oDB->getInsertID() : 0;
}

View file

@ -3,5 +3,5 @@
<column name="handler" type="varchar" size="191" notnull="notnull" />
<column name="args" type="longtext" notnull="notnull" />
<column name="options" type="longtext" notnull="notnull" />
<column name="regdate" type="datetime" notnull="notnull" default="current_timestamp()" index="idx_regdate" />
<column name="regdate" type="datetime" notnull="notnull" index="idx_regdate" />
</table>