Files
HealthLog/prisma/migrations/0390_handover_creator_set_null/migration.sql
T
Marc-André Bombeck 98183700ce fix(handover): keep a claimed handover when its Guardian deletes their account
created_by_id cascaded, so a Guardian who deleted their own account took
every handover they had issued with them, including a claimed one whose
decision the new owner had not made yet. The claim had already applied
the proposal, possibly MANAGE for a co-Guardian, and the owner lost the
one place that asks them to confirm it.

The column is nullable now and cleared on delete (migration 0390). An
unclaimed link without a creator is refused like any link whose creator
lost access. A decision that names a Guardian whose account is gone is
refused with 422 instead of failing on a grant for a missing account.
2026-10-08 22:37:56 +02:00

15 lines
932 B
SQL

-- v1.42 (#959): a handover outlives the Guardian who minted it.
--
-- `created_by_id` cascaded, so a Guardian deleting their own account deleted
-- every handover they had issued, including a claimed one whose decision the
-- new owner had not made yet. The claim had already applied the proposal
-- (possibly MANAGE for a co-Guardian), and the owner lost the one place that
-- asks them to confirm it. The creator is now cleared instead; an unclaimed
-- link without a creator is refused by the claim like any link whose creator
-- lost access.
ALTER TABLE "managed_profile_handovers" ALTER COLUMN "created_by_id" DROP NOT NULL;
ALTER TABLE "managed_profile_handovers" DROP CONSTRAINT "managed_profile_handovers_created_by_id_fkey";
ALTER TABLE "managed_profile_handovers" ADD CONSTRAINT "managed_profile_handovers_created_by_id_fkey" FOREIGN KEY ("created_by_id") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;