Skip to content

Exclusion constraint

An exclusion constraint is a Postgres database constraint that rejects rows which would overlap on a specified set of columns. Syndik8 uses one on the bookings table to enforce that no two confirmed bookings may have overlapping time ranges on the same asset.

The check is database-level, not client-level. It holds regardless of which device the two bookings were created on, and it holds when one booking was created offline and the other was booked online in the meantime — the later write to reach the server is rejected.

The constraint applies only to confirmed bookings. Tentative and pending bookings can overlap each other and confirmed bookings freely; conflict is only checked at the moment a booking becomes confirmed.