Skip to content

Commit 58879bd

Browse files
durable-workflow.github.io: update v2 changes
1 parent 8352787 commit 58879bd

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

docs/features/schedules.md

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,49 @@ $schedule = ScheduleManager::create(
166166
// After 3 triggers, the schedule status becomes 'deleted'.
167167
```
168168

169+
## Backfill
170+
171+
Backfill triggers workflows for past cron occurrences that were missed (e.g., after a schedule was paused, a deployment outage, or late creation):
172+
173+
```php
174+
$results = ScheduleManager::backfill(
175+
$schedule,
176+
from: new DateTimeImmutable('2026-04-10 00:00:00'),
177+
to: new DateTimeImmutable('2026-04-14 00:00:00'),
178+
);
179+
180+
// Returns: [['schedule_id' => '...', 'instance_id' => '...|null', 'cron_time' => '...'], ...]
181+
```
182+
183+
Each missed cron occurrence is triggered sequentially. The schedule's overlap policy applies to each occurrence, or you can override it:
184+
185+
```php
186+
$results = ScheduleManager::backfill(
187+
$schedule,
188+
from: new DateTimeImmutable('2026-04-10 00:00:00'),
189+
to: new DateTimeImmutable('2026-04-14 00:00:00'),
190+
overlapPolicyOverride: ScheduleOverlapPolicy::AllowAll,
191+
);
192+
```
193+
194+
Backfill respects `maxRuns` — if the schedule's remaining actions are exhausted mid-backfill, the operation stops and the schedule is auto-deleted.
195+
196+
Backfill instance IDs are deterministic: `schedule:{scheduleId}:backfill:{timestamp}`.
197+
169198
## History event types
170199

171-
Schedule lifecycle operations produce typed history events for auditability:
200+
When a schedule triggers a workflow, a `ScheduleTriggered` history event is recorded on the started workflow run. This provides lineage from the schedule to the workflow:
201+
202+
```php
203+
// The event payload includes:
204+
// - schedule_id: the schedule's user-facing identifier
205+
// - schedule_ulid: the schedule's internal ULID
206+
// - cron_expression, timezone, overlap_policy
207+
// - trigger_number: which trigger this was (1-indexed)
208+
// - occurrence_time: the cron occurrence time (backfill only)
209+
```
210+
211+
The full set of schedule event types in the history enum:
172212

173213
- `ScheduleCreated` — schedule was created
174214
- `SchedulePaused` — schedule was paused
@@ -178,6 +218,18 @@ Schedule lifecycle operations produce typed history events for auditability:
178218
- `ScheduleDeleted` — schedule was soft-deleted
179219
- `ScheduleTriggerSkipped` — a trigger was skipped due to overlap policy or exhausted actions
180220

221+
`ScheduleTriggered` is the only event currently recorded on workflow history. The others are reserved for future schedule-level audit logging.
222+
223+
## Skip tracking
224+
225+
When a trigger is skipped (due to overlap policy, non-triggerable status, or exhausted actions), the schedule tracks the skip:
226+
227+
- `last_skip_reason` — why the most recent trigger was skipped (e.g., `overlap_policy_skip`, `status_not_triggerable`, `remaining_actions_exhausted`)
228+
- `last_skipped_at` — when the skip occurred
229+
- `skipped_trigger_count` — cumulative number of skipped triggers
230+
231+
These fields are included in `ScheduleManager::describe()` and the Waterline schedule detail API.
232+
181233
## Database
182234

183-
The schedule table (`workflow_schedules`) is created by migration `2026_04_14_000157`. The model class is configurable via `workflows.v2.schedule_model`.
235+
The schedule table (`workflow_schedules`) is created by migration `2026_04_14_000157`. Skip tracking columns are added by migration `2026_04_14_000158`. The model class is configurable via `workflows.v2.schedule_model`.

0 commit comments

Comments
 (0)