Files
HealthLog/prisma/migrations/0157_v1170_cycle_secondary_symptom/migration.sql
T
Marc-André Bombeck 609d248252 feat(cycle): choose cervix as the symptothermal secondary symptom
Let a user pick the Sensiplan double-check's second indicator — cervical
mucus (default) or cervix observation — mirroring the published NFP
standard where the temperature primary sign pairs with one chosen
secondary sign.

- `CycleProfile.secondarySymptom` (MUCUS default | CERVIX) drives which
  second sign the engine confirms against. Casual users keep temperature
  + mucus untouched; the choice lives behind the advanced cycle settings.
- `CycleDayLog` gains the three standard cervix signs — position
  (LOW/HIGH), firmness (FIRM/SOFT), opening/os (CLOSED/OPEN) — as nullable
  columns (migration 0157), wired through Zod, the day-log upsert, the
  DTO, the sync feed, backup/restore and OpenAPI. Additive and
  back-compatible: existing profiles backfill MUCUS, existing day-logs
  keep NULL cervix signs, iOS inherits the fields.
- The engine's `confirmSymptothermal` takes the secondary-symptom choice;
  on CERVIX it confirms against `detectCervixPeak` (last fertile-cervix
  day followed by three closed days — the cervix-closure rule) instead of
  the mucus peak. The double-check still requires BOTH the temperature
  shift AND the secondary peak: a single cervix sign never confirms, and
  the still-learning gate and conservative posture are unchanged.

Engine derived clean-room from the Arbeitsgruppe-NFP / Raith-Paula &
Frank-Herrmann standard.
2026-06-14 15:23:26 +02:00

30 lines
1.4 KiB
SQL

-- v1.17.0 — symptothermal SECONDARY-symptom choice: cervical mucus (default)
-- OR cervix observation, mirroring the Sensiplan/NFP double-check where the
-- temperature primary sign pairs with one chosen second indicator.
--
-- `cycle_profiles.secondary_symptom` picks which second sign the engine uses
-- (MUCUS default | CERVIX); the casual user keeps temperature + mucus and never
-- sees the choice (it lives behind the advanced cycle settings).
--
-- `cycle_day_logs` gains the three standard Sensiplan cervix signs — position
-- (LOW/HIGH), firmness (FIRM/SOFT), opening/os (CLOSED/OPEN) — used as the
-- secondary indicator when secondary_symptom = CERVIX. Fertile = HIGH+SOFT+OPEN;
-- infertile (closure) = LOW+FIRM+CLOSED.
--
-- Additive + back-compatible: every existing profile backfills MUCUS (the prior
-- behaviour) and every existing day-log row keeps NULL cervix signs. iOS
-- inherits the fields without a migration of its own.
CREATE TYPE "secondary_symptom" AS ENUM ('MUCUS', 'CERVIX');
CREATE TYPE "cervix_position" AS ENUM ('LOW', 'HIGH');
CREATE TYPE "cervix_firmness" AS ENUM ('FIRM', 'SOFT');
CREATE TYPE "cervix_opening" AS ENUM ('CLOSED', 'OPEN');
ALTER TABLE "cycle_profiles"
ADD COLUMN "secondary_symptom" "secondary_symptom" NOT NULL DEFAULT 'MUCUS';
ALTER TABLE "cycle_day_logs"
ADD COLUMN "cervix_position" "cervix_position",
ADD COLUMN "cervix_firmness" "cervix_firmness",
ADD COLUMN "cervix_opening" "cervix_opening";