From 5ef5ead98f255cf2480ca41546571f9c0abd485c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 12 May 2026 10:42:56 +0200 Subject: [PATCH] Fix function scheduler document missing --- .../Functions/Http/Functions/Update.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php index b3fcb2c021..10e1f9c47f 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php @@ -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'))