Files
HealthLog/prisma/migrations/0345_cycle_absorbed_start/migration.sql
T
Marc-André Bombeck e822154936 fix(cycle): give back a start that a mis-tapped earlier start folded in
A start logged within one period before an existing start folds that start
into itself and soft-deletes it, since the two are one period entered out of
order. Nothing recorded which start was folded, so taking the earlier start
back could not bring the later one back: a mis-tap on the 5th with a real
start on the 10th, then deleted, left the 10th gone and the cycle before it
reopened.

Migration 0345 adds menstrual_cycles.absorbed_into_id. The folded row names
the start that absorbed it; removing that start restores it, re-derives its
own end and hands its days back to it. The column is needed because a
soft-deleted row alone cannot tell a folded start from one the person
deleted, and the audit trail is not state a removal can read. Deleting a
cycle directly now runs the same shared removal as deleting its day-log.
2026-09-24 12:30:39 +02:00

9 lines
525 B
SQL

-- A period start logged a few days before an existing start folds that start
-- into itself (the same period, entered out of order), soft-deleting it.
-- Nothing recorded which start was folded, so taking the earlier start back
-- could not bring the later one back: a mis-tapped "started" wiped the real
-- start and reopened the cycle before it. The folded row now names the start
-- that absorbed it, and removing that start restores it.
ALTER TABLE "menstrual_cycles"
ADD COLUMN IF NOT EXISTS "absorbed_into_id" TEXT;