From eebf4e3ffbfbb7715e31eb141a8360f26c296edb Mon Sep 17 00:00:00 2001 From: Ritel-T Date: Tue, 1 Sep 2026 04:30:57 +0900 Subject: [PATCH] Add the free Fast migration --- .../migrations_schema_integration_test.go | 1 + .../migrations/233_group_free_openai_fast.sql | 5 +++++ .../group_free_openai_fast_migration_test.go | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 backend/migrations/233_group_free_openai_fast.sql create mode 100644 backend/migrations/group_free_openai_fast_migration_test.go diff --git a/backend/internal/repository/migrations_schema_integration_test.go b/backend/internal/repository/migrations_schema_integration_test.go index 4d32cce370..57f06fd2a8 100644 --- a/backend/internal/repository/migrations_schema_integration_test.go +++ b/backend/internal/repository/migrations_schema_integration_test.go @@ -58,6 +58,7 @@ func TestMigrationsRunner_IsIdempotent_AndSchemaIsUpToDate(t *testing.T) { // groups: OpenAI Live 与 Fast 强制策略都默认关闭,管理员显式开启后才生效。 requireColumn(t, tx, "groups", "allow_live", "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 requireColumn(t, tx, "api_keys", "key", "character varying", 128, false) diff --git a/backend/migrations/233_group_free_openai_fast.sql b/backend/migrations/233_group_free_openai_fast.sql new file mode 100644 index 0000000000..ef84cd31ca --- /dev/null +++ b/backend/migrations/233_group_free_openai_fast.sql @@ -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'; diff --git a/backend/migrations/group_free_openai_fast_migration_test.go b/backend/migrations/group_free_openai_fast_migration_test.go new file mode 100644 index 0000000000..0943e0306b --- /dev/null +++ b/backend/migrations/group_free_openai_fast_migration_test.go @@ -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") +}