mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 21:32:18 +00:00
Server-side prep for the next iOS TestFlight build. Five surfaces land together so the iOS engineer can pick them up in one cut-over: a locked externalId shape for daily-aggregated cumulative HealthKit rows, the SyncMode foundation columns + handshake + bulk-backfill endpoints, a first-class MoodEntry.note column that replaces the legacy tag-based workaround, a cross-source workout dedup helper, and two new MeasurementType enums plus the shared category overlay that drives the iOS permission picker and the future Insights nav.
32 lines
1.5 KiB
SQL
32 lines
1.5 KiB
SQL
-- v1.4.30 — iOS SyncMode foundation (R-E C-2)
|
|
--
|
|
-- Three additive columns the iOS app reads when it pairs with the
|
|
-- server:
|
|
--
|
|
-- measurements.sync_version — monotonic version counter per row.
|
|
-- Default = 1 for legacy rows; the
|
|
-- server bumps it on every update so
|
|
-- paired clients can do last-writer-
|
|
-- wins reconciliation.
|
|
-- measurements.deleted_at — soft-delete timestamp. The
|
|
-- by-external-ids DELETE path flips
|
|
-- this rather than removing rows so
|
|
-- paired iOS clients can reconcile
|
|
-- deletions without losing the audit
|
|
-- trail.
|
|
-- users.last_synced_at — last-known synchronization checkpoint
|
|
-- the iOS SyncMode store reads via
|
|
-- `GET /api/sync/state`.
|
|
--
|
|
-- All three are nullable / defaulted so existing rows + existing iOS
|
|
-- POSTs round-trip unchanged. The `IF NOT EXISTS` guards keep the
|
|
-- migration idempotent against partial historical runs (same posture
|
|
-- as 0058_user_research_mode and 0061_audit_log_carrier).
|
|
|
|
ALTER TABLE "measurements"
|
|
ADD COLUMN IF NOT EXISTS "sync_version" INTEGER NOT NULL DEFAULT 1,
|
|
ADD COLUMN IF NOT EXISTS "deleted_at" TIMESTAMP(3);
|
|
|
|
ALTER TABLE "users"
|
|
ADD COLUMN IF NOT EXISTS "last_synced_at" TIMESTAMP(3);
|