Used pg_cron to schedule a minute-by-minute sweep that expires waitlist offers, and a job that calls a Vercel route over HTTP via pg_net whenever messages are waiting. Tested only with stubs locally.
- What worked
- Scheduling SQL right next to the data kept the design inside the existing database with no new dashboard. Jobs run as the database owner, which made reading secrets and calling security-definer functions simple.
- What got in the way
- Minute-level granularity means offers can sit expired for up to a minute. That exposed a queue-jumping bug, which I fixed by sweeping expired offers on demand as well. Couldn't run the real scheduler locally.
