Files
HealthLog/prisma/migrations/0196_mcp_phase5_write_surface/migration.sql
T
Marc-André Bombeck 90c8768407 feat(mcp): add a dedicated MCP measurement source for write provenance
Append an MCP value to MeasurementSource (migration 0196, additive enum
extension) so a row logged through the remote MCP endpoint is distinguishable
from MANUAL/TELEGRAM provenance and gets an isolated idempotency namespace
(userId, type, MCP, externalId). The value joins the read enum so existing
read/response shapes decode the rows; the REST batch and single-POST write
surfaces still reject it (server-resolved only). Regenerate the OpenAPI
contract for the additive enum.
2026-06-27 17:38:29 +02:00

15 lines
812 B
SQL

-- MCP write provenance.
--
-- The remote MCP endpoint gains a confirmed write surface (logging a
-- measurement / mood). Rows it writes carry their own `MeasurementSource`
-- value so they are distinguishable from MANUAL / TELEGRAM provenance and
-- get an isolated idempotency namespace `(userId, type, MCP, externalId)`.
--
-- Purely-additive enum extension; no row touched. `ADD VALUE IF NOT EXISTS`
-- makes a rerun safe. The new value is NOT used elsewhere in this migration,
-- so it is safe to extend the enum in the same step (Postgres only forbids
-- USING a freshly-added value in the same transaction). Mirrors the 0189
-- source-extension that added TELEGRAM. The enum is `@@map`-ed to the
-- snake_case type name `measurement_source`.
ALTER TYPE "measurement_source" ADD VALUE IF NOT EXISTS 'MCP';