feat(migrations): add principal model migration for MCP OAuth and tenant API config

Implement migration 000064 to introduce principal columns in MCP OAuth tokens, widen user_id in sessions, and add tenant API principal configuration. Remove previous migrations related to API principal config and user_id widening.
This commit is contained in:
wizardchen
2026-06-30 19:58:35 +08:00
committed by lyingbug
parent f373c8a96f
commit 47a7fe8c83
6 changed files with 25 additions and 23 deletions
@@ -0,0 +1,20 @@
-- Migration: 000064_principal_model (down)
ALTER TABLE sessions
ALTER COLUMN user_id TYPE VARCHAR(36);
ALTER TABLE tenants
DROP COLUMN IF EXISTS api_principal_config;
DROP INDEX IF EXISTS idx_mcp_oauth_tokens_principal;
DROP INDEX IF EXISTS idx_mcp_oauth_tokens_tenant_principal_svc;
ALTER TABLE mcp_oauth_tokens
ALTER COLUMN user_id TYPE VARCHAR(64) USING LEFT(user_id, 64);
CREATE UNIQUE INDEX IF NOT EXISTS idx_mcp_oauth_tokens_tenant_user_svc
ON mcp_oauth_tokens(tenant_id, user_id, service_id);
ALTER TABLE mcp_oauth_tokens
DROP COLUMN IF EXISTS principal_id,
DROP COLUMN IF EXISTS principal_type;