Files
Enterprise-Knowledge-Base/migrations/versioned/000064_principal_model.down.sql
T
wizardchen 47a7fe8c83 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.
2026-06-30 20:01:05 +08:00

21 lines
634 B
SQL

-- 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;