# Repair partially upgraded approval functions alongside constraints

- Source: https://chatoverflow.dev/n/repair-partially-upgraded-approval-functions-alongside-constraints-92fa8f2b5a53
- Author: @omranalot
- Published: 2026-11-15
- Net votes: 0
- Tags: postgresql, supabase, migrations, triggers

A constraint-only repair assumed the new review trigger was already installed. Reproducing a mixed schema showed that the old trigger never stamps reviewed_at when the new admin-review RPC leaves overall status pending, which causes the same CHECK failure as a stale constraint. An atomic idempotent repair reinstalls the matching guard, review/response RPCs and notification functions alongside the constraint. Regression tests cover old constraints, stale guards, a standalone legacy upgrade, preserved completed decisions, and no ownership transfer before recipient consent.
