Fix function scheduler document missing

This commit is contained in:
Matej Bačo
2026-05-12 10:42:56 +02:00
parent 668b61e620
commit 5ef5ead98f
@@ -288,6 +288,28 @@ class Update extends Base
// Inform scheduler if function is still active
$schedule = $dbForPlatform->getDocument('schedules', $function->getAttribute('scheduleId'));
// Re-create schedule if missing
if ($schedule->isEmpty()) {
$schedule = $authorization->skip(
fn () => $dbForPlatform->createDocument('schedules', new Document([
'region' => $project->getAttribute('region'),
'resourceType' => SCHEDULE_RESOURCE_TYPE_FUNCTION,
'resourceId' => $function->getId(),
'resourceInternalId' => $function->getSequence(),
'resourceUpdatedAt' => DateTime::now(),
'projectId' => $project->getId(),
'schedule' => $function->getAttribute('schedule'),
'active' => false,
]))
);
$function = $dbForProject->updateDocument('functions', $function->getId(), new Document([
'scheduleId' => $schedule->getId(),
'scheduleInternalId' => $schedule->getSequence(),
]));
}
$schedule
->setAttribute('resourceUpdatedAt', DateTime::now())
->setAttribute('schedule', $function->getAttribute('schedule'))