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
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>
36 lines
1.2 KiB
Go
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
|
|
}
|