Skip to main content

max / makenotwork

mt: make the guest-role migration self-healing 033 tightened the memberships role CHECK with no prior cleanup: a single legacy 'guest' row would hard-fail the whole deploy. Nothing writes 'guest', but fold any such row to 'member' before the ADD CONSTRAINT so the migration is idempotent and can't be blocked by data. Safe to edit in place: 033 landed in the unreleased v0.4.0 cycle and has never been applied to production. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author: Max Johnson <me@maxj.phd> · 2026-07-07 15:10 UTC
Commit: eba2e3cd526a4ee6ff6c526e62a940fa443cf668
Parent: a66a346
1 file changed, +5 insertions, -0 deletions
@@ -6,5 +6,10 @@
6 6 -- tightening is safe. 006's inline CHECK cannot be edited (applied-migration
7 7 -- checksum rule), so replace the auto-named constraint here.
8 8 ALTER TABLE memberships DROP CONSTRAINT IF EXISTS memberships_role_check;
9 + -- Self-heal before tightening: nothing writes 'guest', but if a legacy row from
10 + -- 006's wider CHECK somehow exists, the ADD CONSTRAINT below would hard-fail the
11 + -- whole deploy on it. Fold any such row to 'member' first so the migration is
12 + -- idempotent and can't be blocked by data (fuzz-2026-07-06 migration self-heal).
13 + UPDATE memberships SET role = 'member' WHERE role = 'guest';
9 14 ALTER TABLE memberships ADD CONSTRAINT memberships_role_check
10 15 CHECK (role IN ('owner', 'moderator', 'member'));