All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / test-frontend (push) Has been skipped
CI/CD / test-runners (push) Has been skipped
CI/CD / e2e-smoke (push) Has been skipped
CI/CD / test-go-pg (push) Successful in 2m51s
CI/CD / test-sqlite (push) Successful in 3m1s
CI/CD / build-and-deploy (push) Successful in 1m17s
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.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
|
|
}
|