fix: require usage event cache token schema (#1317)

Co-authored-by: ntduc <ntduc@cpp.ai.vn>
This commit is contained in:
Duc Nguyenandntduc authored and GitHub committed 2026-07-01 18:24:23 +07:00
1 parent 3f5e4f3cc3
commit 1dd8a9dd6d
3 files changed
+52 -1

No files matched your search

+13
View File
@@ -6,6 +6,19 @@ Significant changes, features, and fixes in reverse chronological order.
## 2026-07-01
### Usage event analytics schema gate
**Fixes**
- Bumped required PostgreSQL schema version to include the usage event cache and
thinking token migration required by Resource Event Analytics.
- Added a migration-version regression test so new SQL migrations cannot ship
without updating the binary schema gate.
**Tests**
- Added `internal/upgrade` coverage for required schema version parity.
### Paired DM routing after policy checks
**Fixes**
+1 -1
View File
@@ -2,4 +2,4 @@ package upgrade
// RequiredSchemaVersion is the schema migration version this binary requires.
// Bump this whenever adding a new SQL migration file.
const RequiredSchemaVersion uint = 87
const RequiredSchemaVersion uint = 88
+38
View File
@@ -0,0 +1,38 @@
package upgrade
import (
"path/filepath"
"strconv"
"strings"
"testing"
)
func TestRequiredSchemaVersionMatchesLatestMigration(t *testing.T) {
matches, err := filepath.Glob(filepath.Join("..", "..", "migrations", "*.up.sql"))
if err != nil {
t.Fatalf("glob migrations: %v", err)
}
if len(matches) == 0 {
t.Fatal("no up migrations found")
}
var latest uint64
for _, match := range matches {
base := filepath.Base(match)
prefix, _, ok := strings.Cut(base, "_")
if !ok {
t.Fatalf("migration %q missing numeric prefix", base)
}
version, err := strconv.ParseUint(prefix, 10, 64)
if err != nil {
t.Fatalf("parse migration prefix %q: %v", base, err)
}
if version > latest {
latest = version
}
}
if RequiredSchemaVersion != uint(latest) {
t.Fatalf("RequiredSchemaVersion = %d, latest migration = %d", RequiredSchemaVersion, latest)
}
}