Files
ai-gateway-go/migrations/000009_legacy_id_mappings.sql
superidou 5759c1862e AI Gateway Go 0.10.0 源码快照 + 旗舰版需求规划报告
M0-M7 已完成:核心网关(身份/RBAC/TOTP/OIDC/SAML/Provider/配额/路由/内容策略/审计/定价)+ 资源市场(MCP/Skills/数字员工)。
含 22 个 PostgreSQL 迁移、管理端/门户端前端源码、OpenAPI 契约、部署 compose。

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-12 11:45:54 +08:00

20 lines
801 B
SQL

CREATE TABLE IF NOT EXISTS gateway.legacy_id_mappings (
source_system varchar(64) NOT NULL,
entity_type varchar(128) NOT NULL,
legacy_id text NOT NULL,
new_id uuid NOT NULL,
metadata jsonb NOT NULL DEFAULT '{}'::jsonb,
imported_at timestamptz NOT NULL DEFAULT clock_timestamp(),
PRIMARY KEY (source_system, entity_type, legacy_id),
UNIQUE (source_system, entity_type, new_id),
CHECK (length(source_system) BETWEEN 1 AND 64),
CHECK (length(entity_type) BETWEEN 1 AND 128),
CHECK (length(legacy_id) BETWEEN 1 AND 256)
);
CREATE INDEX IF NOT EXISTS legacy_id_mappings_new_id_idx
ON gateway.legacy_id_mappings (new_id);
COMMENT ON TABLE gateway.legacy_id_mappings IS
'Idempotent compatibility map from legacy entity IDs to deterministic UUIDv5 IDs.';