This repository has been archived on 2026-04-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
core/server/handlers/starlark_helpers.go
Jeffrey Smith b8a4c516ff
All checks were successful
CI/CD / detect-changes (pull_request) Successful in 4s
CI/CD / test-frontend (pull_request) Has been skipped
CI/CD / test-runners (pull_request) Has been skipped
CI/CD / e2e-smoke (pull_request) Has been skipped
CI/CD / test-go-pg (pull_request) Successful in 2m43s
CI/CD / test-sqlite (pull_request) Successful in 2m52s
CI/CD / build-and-deploy (pull_request) Successful in 2m15s
Feat v0.9.2 Starlark converter consolidation + snapshot cleanup (#75)
Consolidate duplicate Go↔Starlark converters into sandbox/convert.go
and snapshot parsers into models/snapshot.go. Standardize snapshot
creation on wrapped format. Net -393 lines across 21 files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 14:20:05 +00:00

36 lines
1.2 KiB
Go

package handlers
import (
"encoding/json"
"log"
)
// ParseSchemaVersion extracts the schema_version from a package manifest.
func ParseSchemaVersion(manifest any) int {
switch m := manifest.(type) {
case map[string]any:
if v, ok := m["schema_version"].(float64); ok {
return int(v)
}
case json.RawMessage:
var s struct {
SchemaVersion int `json:"schema_version"`
}
if err := json.Unmarshal(m, &s); err == nil {
return s.SchemaVersion
}
}
return 0
}
// RunSchemaMigrations logs a schema version change during package update.
//
// Only additive schema changes are supported: extensions can ADD columns and
// tables via db_tables in the manifest, but cannot modify or delete existing
// schema. If a migration between versions requires destructive changes,
// uninstall and reinstall the package manually.
func RunSchemaMigrations(ctx any, sandbox any, stores any, db any, isPostgres bool, packageID string, manifest any, fromVersion, toVersion int) error {
log.Printf("[pkg-migrate] %s: schema version %d → %d (only additive changes are applied automatically; destructive migrations require manual uninstall/reinstall)", packageID, fromVersion, toVersion)
return nil
}