Files
HealthLog/prisma/migrations/0060_onboarding_step_not_null/migration.sql
T
Marc-André Bombeck 17b8d8d2c2 chore(release): v1.4.25
Largest feature delta in the v1.4.x line. Insights expands into seven dedicated metric sub-pages; GLP-1 medication tracking lands end-to-end (drug-level chart with Research Mode acknowledgment, EMA titration ladder, cadence + compliance, side-effect taxonomy, pen/vial inventory); cross-source priority becomes a two-axis resolver; per-user timezone threads through ten analytics surfaces; Withings activity + sleep v2 sync; onboarding rebuilt as a nested-route wizard; Personal Records ship end-to-end; Health Score provenance accordion; Coach runs native first-party prompts across six locales with a 1800-assertion refusal-probe matrix; OpenAPI drift gate hard-fails; multi-arch GHCR image. Migrations 0043 through 0060 are additive and forward-only. PROMPT_VERSION 4.24.0 → 4.25.0 with GROUND RULE 9 (refuses dose recommendations) and GROUND RULE 15 (refuses drug-level estimates with MDR + MDCG 2021-24 cites).

See CHANGELOG.md for the full per-section delta.
2026-05-14 23:49:32 +02:00

26 lines
1.2 KiB
SQL

-- v1.4.25 W21 Fix-O — Backfill `onboarding_step` and flip column to NOT NULL.
--
-- Migration 0057 shipped `onboarding_step INTEGER DEFAULT 0` — nullable on
-- purpose so the additive DDL didn't risk a long table-rewrite during the
-- W14b deploy. The wizard mount code (`src/app/onboarding/page.tsx`) treats
-- `null` as `0`, the POST route (`src/app/api/onboarding/step/route.ts`)
-- widens its conditional-update WHERE to `OR onboardingStep IS NULL` when
-- the caller is at step 0 — all defensive against the tri-state surface.
--
-- This migration closes that tri-state: every legacy pre-W14b row that
-- still carries a NULL is backfilled to 0 (the same value the read-path
-- already substitutes), then the column is flipped to NOT NULL. New
-- inserts continue to land at the DEFAULT 0 — schema.prisma now mirrors
-- the DB shape: `onboardingStep Int @default(0)` without the `?`.
--
-- Idempotent — re-running on a database that's already been flipped is a
-- no-op for the UPDATE (no rows match) and the ALTER COLUMN tolerates
-- SET NOT NULL on an already-NOT NULL column.
UPDATE "users"
SET "onboarding_step" = 0
WHERE "onboarding_step" IS NULL;
ALTER TABLE "users"
ALTER COLUMN "onboarding_step" SET NOT NULL;