From a2d01ed3ad035ce2aeaaa3ae2e8ee45aeb1e3500 Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Wed, 11 Mar 2026 20:54:23 -0700 Subject: [PATCH] fix(encryptid): drop CHECK constraint before migrating authority values The old constraint rejected new values during UPDATE. Must drop first, migrate data, then add new constraint. Co-Authored-By: Claude Opus 4.6 --- src/encryptid/schema.sql | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/encryptid/schema.sql b/src/encryptid/schema.sql index a510ca8..ac11fd8 100644 --- a/src/encryptid/schema.sql +++ b/src/encryptid/schema.sql @@ -457,6 +457,9 @@ CREATE INDEX IF NOT EXISTS idx_legacy_identities_pubkey ON legacy_identities(leg -- MIGRATION: Rename authority verticals (voting/moderation/curation/treasury/membership → gov-ops/fin-ops/dev-ops) -- ============================================================================ +-- Drop old CHECK constraint first so UPDATEs can set new values +ALTER TABLE delegations DROP CONSTRAINT IF EXISTS delegations_authority_check; + -- Migrate existing delegation data UPDATE delegations SET authority = 'gov-ops' WHERE authority IN ('voting', 'moderation'); UPDATE delegations SET authority = 'fin-ops' WHERE authority = 'treasury'; @@ -472,6 +475,5 @@ UPDATE trust_events SET authority = 'gov-ops' WHERE authority IN ('voting', 'mod UPDATE trust_events SET authority = 'fin-ops' WHERE authority = 'treasury'; UPDATE trust_events SET authority = 'dev-ops' WHERE authority IN ('curation', 'membership'); --- Update CHECK constraint on delegations table -ALTER TABLE delegations DROP CONSTRAINT IF EXISTS delegations_authority_check; +-- Add new CHECK constraint with updated values ALTER TABLE delegations ADD CONSTRAINT delegations_authority_check CHECK (authority IN ('gov-ops', 'fin-ops', 'dev-ops', 'custom'));