Recurring schedules stored as rule definitions, not pre-expanded individual rows
Why it matters
Storing a host's Monday-through-Friday 9-to-5 availability as 260 individual database rows — one per workday — is an ISO 25010 functional-correctness failure masquerading as a schema decision. Pre-expanded rows mean adding a single exception (a vacation day) requires a DELETE and INSERT instead of an exception record. Querying a year's availability requires scanning hundreds of rows instead of parsing one RRULE string. Editing the recurring pattern requires a bulk UPDATE. The real business risk: a host who changes their hours sees stale slots appear because the expansion was done at write time, not at query time.
Severity rationale
Low because pre-expanded storage causes maintenance debt and stale-schedule bugs rather than immediate data loss, but it blocks correct exception handling and makes schedule edits error-prone.
Remediation
Store recurring availability as a single RRULE string per rule, with a separate exceptions table for overrides. Parse and expand at query time using the rrule package.
-- supabase/migrations/YYYYMMDDHHMMSS_recurring_availability.sql
CREATE TABLE recurring_availability (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
resource_id UUID NOT NULL,
rrule TEXT NOT NULL -- e.g. FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR
);
CREATE TABLE availability_exceptions (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
recurring_id UUID NOT NULL REFERENCES recurring_availability(id),
exception_date DATE NOT NULL,
is_available BOOLEAN NOT NULL DEFAULT FALSE
);
// src/lib/availability.ts
import { rrulestr } from 'rrule'
export async function getSlots(resourceId: string, start: Date, end: Date) {
const rec = await db.recurringAvailability.findFirst({ where: { resourceId } })
if (!rec) return []
return rrulestr(rec.rrule, { dtstart: start }).between(start, end)
}
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Calendar & Availability Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · functional-correctness — Functional Correctness — rule-based storage is required for correct recurring availability computation
Taxons
History
- 2026-04-18·v1.0.0·Initial import from booking-calendar-availability·automated