Skip to content

Database schema

The worker uses one D1 database (stayonthesnow) bound as env.DB. Migrations live in migrations/*.sql and run via npx wrangler d1 migrations apply.

Tables

TableMigrationPurpose
bookings0001Beds24 booking cache
migration_log0001Generic audit trail (workflow triggers, webhook hits, errors)
feature_flags0001 / 0003 / 0010 / 0014 / 0028 / 0034Per-workflow shadow + enable toggles
info_items0001Beds24 infoItem cache (TBD: may be deprecated)
messages0001Beds24 thread message cache
shadow_predictions0002 / 0006Workflow phase predictions (action_at + fields)
workflow_runs0001(legacy, may be deprecated)
workflow_instances0004(workflow_name, resource_id) → instance_id
property_config0005 / 0009 / 0014 / 0026 / 0030 / 0031 / 0032 / 0033Per-property settings
form_submissions0007 / 0008Check-in / check-out form submissions
cleanings0011 / 0012 / 0013 / 0015 / 0016Per-booking cleaning state
pre_checkin_submissions0017 / 0018 / 0019 / 0020 / 0021 / 0027 / 0029Pre-check-in form state
mailgun_events0022 / 0023Mailgun webhook events
twilio_events0024Twilio status callback events
outbound_log0024Cross-channel send log
beds24_messages0024Outbound thread messages + verification
alert_log0025Dedup log for repeat alerts

Migrations applied (as of latest)

0001_initial.sql — bookings, migration_log, feature_flags
0002_shadow_phases.sql — shadow_predictions
0003_booking_flag_flag.sql — feature_flags row for booking-flag
0004_workflow_instances.sql — workflow_instances
0005_property_config.sql — property_config (initial cols)
0006_shadow_predictions_dedup.sql — unique index
0007_form_submissions.sql — form_submissions
0008_form_overrides.sql — form_overrides column
0009_property_cleaners.sql — cleaners JSON column
0010_cleaner_sms_flag.sql — cleaner-sms feature flag
0011_cleanings.sql — cleanings (initial cols)
0012_cleanings_arrival_date.sql — arrival_date column
0013_cleanings_touchpoints.sql — touchpoint cols
0014_cleaner_emails_and_flag.sql — cleaner emails + cleaner-email flag
0015_cleanings_next_arrival.sql — next_arrival_date column
0016_cleanings_eta_miss.sql — eta_miss_alerted_at column
0017_pre_checkin_submissions.sql — pre_checkin_submissions (initial)
0018_pre_checkin_signature.sql — signature cols
0019_pre_checkin_selfie.sql — selfie cols
0020_pre_checkin_addons.sql — addon cols
0021_pre_checkin_payments.sql — Stripe cols
0022_mailgun_events.sql — mailgun_events
0023_mailgun_event_tagging.sql — booking_id + purpose cols
0024_delivery_observability.sql — twilio_events, outbound_log, beds24_messages
0025_alert_log.sql — alert_log
0026_property_addon_pricing.sql — addon_pricing JSON
0027_addon_decisions.sql — per-addon decision tracking
0028_pre_arrival_messages_flag.sql — pre-arrival-messages flag
0029_pre_arrival_message_gate.sql — last_pre_arrival_msg_at
0030_property_arrival_instructions.sql — arrival_instructions_short
0031_property_lock_box.sql — lock_box_code
0032_property_arrival_body.sql — arrival_message_body
0033_property_cohost_emails.sql — cohost_emails JSON
0034_form_bridges_flag.sql — form-bridges flag

Read more

For column details on each, see the migration files or /admin/property/{id} for the visual config editor.