Files
seminarhof-e2e-mqock9p6/db/sqlite/0006-booking-lifecycle.sql
2026-06-22 00:17:20 +02:00

18 lines
1.2 KiB
SQL

-- Booking lifecycle milestones.
--
-- The status enum is reshaped to a lean "bucket": enquiry | reserved |
-- confirmed | ended | cancelled. The contract + deposit progression that
-- runs inside `reserved` (over ~1 year) is tracked as the columns below plus the
-- deposit row on the invoice table — NOT as extra statuses. A daily cron reads
-- these columns; nothing here runs a long-lived workflow.
ALTER TABLE booking ADD COLUMN contract_sent_at TEXT; -- ISO; day-0 anchor + R1 idempotency guard
ALTER TABLE booking ADD COLUMN contract_response TEXT; -- 'approved' | 'declined' | null (pending)
ALTER TABLE booking ADD COLUMN contract_response_at TEXT; -- ISO
ALTER TABLE booking ADD COLUMN deposit_reminder_sent_at TEXT; -- ISO; R2 idempotency guard
ALTER TABLE booking ADD COLUMN flagged_at TEXT; -- ISO; set when admin review is needed
ALTER TABLE booking ADD COLUMN flag_reason TEXT; -- 'deposit_overdue' | 'short_window' | 'contract_declined'
-- Collapse the two retired statuses onto the new bucket (for any non-reset DB).
UPDATE booking SET status = 'reserved' WHERE status = 'form_received';
UPDATE booking SET status = 'confirmed' WHERE status = 'deposit_paid';