diff --git a/backend/internal/repository/migrations_schema_integration_test.go b/backend/internal/repository/migrations_schema_integration_test.go index d90cc4f4b5..4d32cce370 100644 --- a/backend/internal/repository/migrations_schema_integration_test.go +++ b/backend/internal/repository/migrations_schema_integration_test.go @@ -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) diff --git a/backend/migrations/232_group_force_openai_fast.sql b/backend/migrations/232_group_force_openai_fast.sql new file mode 100644 index 0000000000..aaf0f4f4fa --- /dev/null +++ b/backend/migrations/232_group_force_openai_fast.sql @@ -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'; diff --git a/backend/migrations/group_force_openai_fast_migration_test.go b/backend/migrations/group_force_openai_fast_migration_test.go new file mode 100644 index 0000000000..100c1294ab --- /dev/null +++ b/backend/migrations/group_force_openai_fast_migration_test.go @@ -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") +}