Add the free Fast migration

This commit is contained in:
Ritel-T
2026-09-01 04:34:23 +09:00
parent c7cf84ad39
commit eebf4e3ffb
3 changed files with 24 additions and 0 deletions
@@ -58,6 +58,7 @@ func TestMigrationsRunner_IsIdempotent_AndSchemaIsUpToDate(t *testing.T) {
// groups: OpenAI Live 与 Fast 强制策略都默认关闭,管理员显式开启后才生效。 // groups: OpenAI Live 与 Fast 强制策略都默认关闭,管理员显式开启后才生效。
requireColumn(t, tx, "groups", "allow_live", "boolean", 0, false) requireColumn(t, tx, "groups", "allow_live", "boolean", 0, false)
requireColumn(t, tx, "groups", "force_openai_fast", "boolean", 0, false) requireColumn(t, tx, "groups", "force_openai_fast", "boolean", 0, false)
requireColumn(t, tx, "groups", "free_openai_fast", "boolean", 0, false)
// api_keys: key length should be 128 // api_keys: key length should be 128
requireColumn(t, tx, "api_keys", "key", "character varying", 128, false) requireColumn(t, tx, "api_keys", "key", "character varying", 128, false)
@@ -0,0 +1,5 @@
ALTER TABLE groups
ADD COLUMN IF NOT EXISTS free_openai_fast BOOLEAN NOT NULL DEFAULT FALSE;
COMMENT ON COLUMN groups.free_openai_fast IS
'Whether Fast/priority requests in this OpenAI/Composite group are billed to users at Standard price';
@@ -0,0 +1,18 @@
package migrations
import (
"strings"
"testing"
"github.com/stretchr/testify/require"
)
func TestGroupFreeOpenAIFastMigration(t *testing.T) {
content, err := FS.ReadFile("233_group_free_openai_fast.sql")
require.NoError(t, err)
sql := strings.Join(strings.Fields(string(content)), " ")
require.Contains(t, sql,
"ADD COLUMN IF NOT EXISTS free_openai_fast BOOLEAN NOT NULL DEFAULT FALSE")
require.Contains(t, sql, "COMMENT ON COLUMN groups.free_openai_fast")
}