Files
tokens-reef/backend/migrations/045_add_accounts_extra_index.sql
Developer da36506b89 fix: resolve P0/P1 code quality issues
P0 fixes:
- ModelError.Is(): use exact matching instead of substring contains()
- shouldClearStickySession: add context param for cancellation/tracing

P1 fixes:
- TODO stubs: return 501 Not Implemented errors
- validateInstanceSignature: deduplicate to shared validateCodeSignature()
- Error messages: standardize to English only
- http.go: remove pseudo if-else with duplicate branches
2026-03-31 11:39:18 +08:00

14 lines
514 B
SQL

-- Migration: 045_add_accounts_extra_index
-- 为 accounts.extra 字段添加 GIN 索引,优化 FindByExtraField 查询性能
-- 用于支持通过 extra 字段中的 linked_openai_account_id 快速查找关联的 Sora 账号
CREATE INDEX IF NOT EXISTS idx_accounts_extra_gin
ON accounts USING GIN (extra);
-- 查询示例(使用 @> 操作符)
-- EXPLAIN ANALYZE
-- SELECT * FROM accounts
-- WHERE platform = 'sora'
-- AND extra @> '{"linked_openai_account_id": 123}'::jsonb
-- AND deleted_at IS NULL;