/ Cases / Lodging / Bookings

Direct vacation rental bookings, no commission

Instant or request-to-book reservations, a calendar synced with Airbnb and an anti-overlap lock in the database: two people can't book the same night.

/ Atitlán's House/ 2026.09/ Reconciliation every 15 min

15 min

reconciliation with Airbnb

0

nights sold twice

/ The problem

Every booking went through Airbnb and its commission. Opening a direct channel came with a risk: selling the same night twice.

/ What we built

  • Instant or request-to-book: the owner accepts with a signed link.
  • Two-way calendar with Airbnb and reconciliation every 15 minutes.
  • An exclusion constraint in Postgres: the database itself blocks two overlapping bookings.
  • Holds that expire on their own if unpaid.

/ How it works

  1. 01Guest books direct
  2. 02Temporary hold
  3. 03Payment
  4. 04Airbnb calendar updated

/ Real code

supabase/migrations/20260908000001_init_bookings.sqlsql
-- ── Bloqueos (Airbnb por iCal, manuales) ─────────────────────────────────
create table blocks (
  property_id  uuid not null references properties on delete cascade,
  nights       daterange not null,   -- [inicio, fin)
  source       block_source not null default 'manual',
  external_uid text,                 -- UID del VEVENT; para upsert idempotente
  -- …
  unique (property_id, source, external_uid)
);
-- …
-- ── Reservas propias ─────────────────────────────────────────────────────
create table bookings (
  property_id    uuid not null references properties on delete restrict,
  nights         daterange not null,  -- [checkin, checkout)
  status         booking_status not null default 'hold',
  source         booking_source not null default 'web',
  hold_expires_at timestamptz,        -- solo mientras status = hold
  -- …
  constraint nights_valid check (lower(nights) < upper(nights)),
  -- Nunca dos reservas vivas solapadas en la misma casa.
  exclude using gist (property_id with =, nights with &&)
    where (status in ('hold', 'pending_payment', 'confirmed'))
);

■ Airbnb blocks are imported idempotently by iCal UID, and the EXCLUDE constraint makes it impossible to store two overlapping bookings.

/ Stack

AstroCloudflare WorkersPostgres EXCLUDEiCalStripe