Files
HealthLog/prisma/migrations/0398_integration_plan_and_scope_state/migration.sql
T
Marc-André Bombeck 39b0cabb43 fix(withings): keep the sync inside the account's API plan
Withings split its public API into plans on 2026-10-12. A request naming
one meastype outside the free plan is refused whole with status 277, so
every measure sync stopped importing anything, and the 200..299 reauth
range parked the connection at error_reauth.

The measure, sleep-summary and ECG legs now drop the documented advanced
types on a 277, split the rest until the refused keys are isolated
(bounded), remember the refusal per connection and re-probe weekly. 277
is classified persistent and never enters the ledger; connections parked
over it are lifted by the fallback tick, and the held watermark lets the
next run read the whole gap.
2026-10-14 18:53:58 +02:00

19 lines
1.1 KiB
SQL

-- v1.42.3 — remember what an integration's upstream refuses by contract.
--
-- Withings split its public API into plans on 2026-10-12. A self-hoster's own
-- developer app sits on the free plan, and a request that names a meastype
-- outside that plan is refused whole with status 277. The sync now drops the
-- gated types and keeps the rest; this column remembers which ones per
-- connection so later runs skip them without a refused round trip, plus when
-- that was last checked so a plan upgrade is noticed within a week.
--
-- Oura's current authorization server enforces scopes per collection. A grant
-- issued before HealthLog asked for `spo2` and `heart_health` answers 401 on
-- the collections behind them while every other collection succeeds. This
-- column holds those collection names so the Oura card can ask for a single
-- reconnect instead of painting the connection as broken.
--
-- Additive only: two nullable columns, no default, no rewrite, no data change.
ALTER TABLE "withings_connections" ADD COLUMN IF NOT EXISTS "api_plan_state" JSONB;
ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "oura_scope_denied" JSONB;