024_add_gemini_tier_id.sql 849 B

123456789101112131415161718192021222324252627282930
  1. -- +goose Up
  2. -- +goose StatementBegin
  3. -- 为 Gemini Code Assist OAuth 账号添加默认 tier_id
  4. -- 包括显式标记为 code_assist 的账号,以及 legacy 账号(oauth_type 为空但 project_id 存在)
  5. UPDATE accounts
  6. SET credentials = jsonb_set(
  7. credentials,
  8. '{tier_id}',
  9. '"LEGACY"',
  10. true
  11. )
  12. WHERE platform = 'gemini'
  13. AND type = 'oauth'
  14. AND jsonb_typeof(credentials) = 'object'
  15. AND credentials->>'tier_id' IS NULL
  16. AND (
  17. credentials->>'oauth_type' = 'code_assist'
  18. OR (credentials->>'oauth_type' IS NULL AND credentials->>'project_id' IS NOT NULL)
  19. );
  20. -- +goose StatementEnd
  21. -- +goose Down
  22. -- +goose StatementBegin
  23. -- 回滚:删除 tier_id 字段
  24. UPDATE accounts
  25. SET credentials = credentials - 'tier_id'
  26. WHERE platform = 'gemini'
  27. AND type = 'oauth'
  28. AND credentials ? 'tier_id';
  29. -- +goose StatementEnd