feat(db): add delegate_party_id column to mpc_sessions table

Add delegate_party_id column to track which party is acting as delegate
(generates and returns user share instead of storing it).

Changes:
- Add delegate_party_id VARCHAR(255) column with default empty string
- Add partial index for faster lookups when delegate party is present
- Include up and down migrations

This fixes the issue where delegate party selection worked but the delegate_party
field was not being returned in API responses due to missing database column.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-06 05:50:01 -08:00
parent 36e1359f43
commit 391448063f
2 changed files with 13 additions and 0 deletions

View File

@ -0,0 +1,3 @@
-- Remove delegate_party_id column from mpc_sessions table
DROP INDEX IF EXISTS idx_mpc_sessions_delegate_party;
ALTER TABLE mpc_sessions DROP COLUMN IF EXISTS delegate_party_id;

View File

@ -0,0 +1,10 @@
-- Add delegate_party_id column to mpc_sessions table
-- This column stores the ID of the delegate party that will return user's share
-- Only populated for keygen sessions with require_delegate=true
ALTER TABLE mpc_sessions ADD COLUMN delegate_party_id VARCHAR(255) DEFAULT '';
-- Add index for faster lookups by delegate party
CREATE INDEX idx_mpc_sessions_delegate_party ON mpc_sessions(delegate_party_id) WHERE delegate_party_id != '';
-- Add comment
COMMENT ON COLUMN mpc_sessions.delegate_party_id IS 'The delegate party ID that generates and returns user share (for keygen sessions with delegate)';