---
title: Merge Schedules
description: How the merge queue tests a pull request before its merge schedule opens, and how it keeps that pull request from holding up the ones that can merge now.
---

A [queue rule](/merge-queue/rules) can limit when its pull requests merge with a
[`schedule`](/configuration/data-types#schedule) in its `merge_conditions`.
Outside that window, a pull request's merge schedule is closed: it stays in the
queue and does not merge, however green its checks are. Mergify tests it ahead
of the window, so it merges as soon as the window opens, and keeps it from
holding up the pull requests that can merge now.

## When to use merge schedules

Use one when some pull requests should only land at certain hours, such as
dependency updates while someone is around to watch them deploy.

## Setting up a merge schedule

Add the `schedule` to the `merge_conditions` of the queue rule that should wait:

```yaml
queue_rules:
  - name: dependencies
    queue_conditions:
      - author = dependabot[bot]
    merge_conditions:
      - check-success = ci
      - or:
          - label = hotfix
          - schedule = Mon-Fri 09:00-11:00[Europe/Paris]
  - name: default
    merge_conditions:
      - check-success = ci
```

Here, dependency updates merge on weekday mornings, unless labeled `hotfix`,
and every other pull request merges as soon as its checks pass. In the figures,
#21 is a dependency update and the others come from your team.

### Which schedules Mergify recognizes

Mergify treats a merge schedule as closed only when the queue rule's conditions
prove it:

- A `schedule` or [`current-datetime`](/configuration/conditions#attributes-list)
  condition listed in `merge_conditions`, or nested in an `and`, closes the rule
  for every pull request outside its window.

- In an `or` with `label` or `author` conditions, as above, it closes the rule
  only for the pull requests that match none of them. A dependency update
  labeled `hotfix` has its schedule open at any hour.

When a schedule sits in an `or` with any other condition, Mergify treats it as
open: the pull request is tested in its turn and, if its checks pass outside
the window, waits at its place like any other unmet merge condition.

## Testing before the window opens

A pull request whose schedule is closed keeps its place in the queue, but is
tested behind the pull requests that can merge now, before its window opens.
Once its checks pass, its batch waits with the
[batch status](/configuration/data-types#batch-status) `waiting_schedule` and
merges when the window opens.

> **Figure:** #21's schedule is closed, so #22 and #23 are tested first and #21 behind them.
>
> Queue positions, front on the left. Queued: 21, whose schedule is closed, then 22 and 23. Tested at night: 22, 23, then 21.

## Giving up its place in the queue

A batch is tested on top of the batches ahead of it, so one waiting for its
window would hold up everything behind it. Instead, it gives up its place to any
batch behind it that could merge sooner, and is tested again behind it. A batch
holding pull requests that can merge now and ones that cannot is split the same
way, when that merges the first ones sooner.

> **Figure:** #21 cannot merge before 09:00, so it gives up its place: #22 is tested again without it and merges.
>
> Queue positions, front on the left. After 11:00: 21 waits for its schedule, and 22 passed its checks on top of it. After 21 gives way: 22 is tested first, then 21.

## Giving up its check slot

[`max_parallel_checks`](/merge-queue/performance#parallel-checks) caps how many
batches run their checks at once, and a
[per-scope capacity](/merge-queue/queue-modes#limiting-concurrency-per-scope)
caps them within a scope. A batch tested ahead of its schedule only borrows a
slot no pull request needed: when one that can merge now is waiting for a slot,
the batch gives it back and is tested again once a slot is free. It does so
whatever
[`allow_checks_interruption`](/merge-queue/priority#managing-check-interruptions-based-on-priority)
is set to: a schedule is not a priority.

> **Figure:** Every slot is taken, so #21, tested ahead of its window, gives its slot to #23, which can merge now.
>
> Three check slots and a waiting column. First: 21, whose schedule is closed, 24 and 25 run their checks, and 23 waits. Then: 23 runs in 21's slot, and 21 waits.

## What you see on the pull request

Giving up its place or its check slot interrupts the checks of the waiting
pull request and of those batched with it or tested on top of it. They report
the
[`schedule-blocked-ahead-yielded`](/configuration/data-types#queue-dequeue-reason)
dequeue reason and stay in the queue, to be tested again on their own.

## See also

- [Batches](/merge-queue/batches)
- [Priority](/merge-queue/priority)
- [Scheduled freezes](/merge-protections/freeze)
