mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 15:42:24 +00:00
A reading sent with a measurements:write token keeps its EXTERNAL source and now points at the token that carried it (measurements.ingest_token_id). Every stored row answers a server-resolved appleHealthMirror: true for WITHINGS, IMPORT and MANUAL, the token's choice for EXTERNAL, false otherwise. The plain list accepts appleHealthMirror=true so a client can page exactly those rows. Migration 0476 adds the columns and links existing EXTERNAL readings only where one measurement token provably sent them; 0477 builds the index concurrently. Backups carry the link and a restore keeps it only for a token the account still holds. A guard holds every EXTERNAL writer to setting the link.
9 lines
495 B
SQL
9 lines
495 B
SQL
-- The rows a measurement token carried (#1272): walked by the
|
|
-- `measurementMirror` domain of `/api/sync/changes` in id order, and looked up
|
|
-- by the foreign key's SET NULL. Built CONCURRENTLY so writes to
|
|
-- `measurements` carry on during the build; a concurrent build must be the
|
|
-- only statement in its file. Most rows have no token, so the index stays
|
|
-- small.
|
|
CREATE INDEX CONCURRENTLY IF NOT EXISTS "measurements_ingest_token_id_id_idx"
|
|
ON "measurements" ("ingest_token_id", "id");
|