Add the group Fast migration

This commit is contained in:
Ritel-T
2026-09-01 04:19:38 +09:00
parent 200602b41b
commit aa679efe41
3 changed files with 25 additions and 1 deletions
@@ -55,8 +55,9 @@ func TestMigrationsRunner_IsIdempotent_AndSchemaIsUpToDate(t *testing.T) {
requireColumn(t, tx, "accounts", "session_window_status", "character varying", 20, true)
requireIndex(t, tx, "accounts", "idx_accounts_autopause_expiry_due")
// groups: OpenAI Live 默认关闭,管理员显式开启后才可访问。
// groups: OpenAI Live 与 Fast 强制策略都默认关闭,管理员显式开启后才生效。
requireColumn(t, tx, "groups", "allow_live", "boolean", 0, false)
requireColumn(t, tx, "groups", "force_openai_fast", "boolean", 0, false)
// api_keys: key length should be 128
requireColumn(t, tx, "api_keys", "key", "character varying", 128, false)
@@ -0,0 +1,5 @@
ALTER TABLE groups
ADD COLUMN IF NOT EXISTS force_openai_fast BOOLEAN NOT NULL DEFAULT FALSE;
COMMENT ON COLUMN groups.force_openai_fast IS
'Force OpenAI gateway requests in this group to use service_tier=priority before global Fast/Flex policy evaluation';
@@ -0,0 +1,18 @@
package migrations
import (
"strings"
"testing"
"github.com/stretchr/testify/require"
)
func TestGroupForceOpenAIFastMigration(t *testing.T) {
content, err := FS.ReadFile("232_group_force_openai_fast.sql")
require.NoError(t, err)
sql := strings.Join(strings.Fields(string(content)), " ")
require.Contains(t, sql,
"ADD COLUMN IF NOT EXISTS force_openai_fast BOOLEAN NOT NULL DEFAULT FALSE")
require.Contains(t, sql, "COMMENT ON COLUMN groups.force_openai_fast")
}