diff --git a/Makefile b/Makefile index 24d610b..3901ea6 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ TARGET = ./cc-backend VAR = ./var DB = ./var/job.db FRONTEND = ./web/frontend -VERSION = 0.1 +VERSION = 1 GIT_HASH := $(shell git rev-parse --short HEAD || echo 'development') CURRENT_TIME = $(shell date +"%Y-%m-%d:T%H:%M:%S") LD_FLAGS = '-s -X main.buildTime=${CURRENT_TIME} -X main.version=${VERSION} -X main.hash=${GIT_HASH}' diff --git a/cmd/cc-backend/main.go b/cmd/cc-backend/main.go index 505cb8b..360d6d7 100644 --- a/cmd/cc-backend/main.go +++ b/cmd/cc-backend/main.go @@ -84,6 +84,8 @@ func main() { fmt.Printf("Version:\t%s\n", version) fmt.Printf("Git hash:\t%s\n", hash) fmt.Printf("Build time:\t%s\n", buildTime) + fmt.Printf("SQL db version:\t%d\n", repository.Version) + fmt.Printf("Job archive version:\t%d\n", archive.Version) os.Exit(0) } diff --git a/internal/api/rest.go b/internal/api/rest.go index b9f188f..5bad0ad 100644 --- a/internal/api/rest.go +++ b/internal/api/rest.go @@ -30,7 +30,7 @@ import ( ) // @title ClusterCockpit REST API -// @version 0.2.0 +// @version 1 // @description API for batch job control. // @tag.name Job API diff --git a/internal/repository/migration.go b/internal/repository/migration.go index dd30272..07e1c90 100644 --- a/internal/repository/migration.go +++ b/internal/repository/migration.go @@ -17,7 +17,7 @@ import ( "github.com/golang-migrate/migrate/v4/source/iofs" ) -const supportedVersion uint = 3 +const Version uint = 3 //go:embed migrations/* var migrationFiles embed.FS @@ -65,13 +65,13 @@ func checkDBVersion(backend string, db *sql.DB) { } } - if v < supportedVersion { - log.Warnf("Unsupported database version %d, need %d.\nPlease backup your database file and run cc-backend --migrate-db", v, supportedVersion) + if v < Version { + log.Warnf("Unsupported database version %d, need %d.\nPlease backup your database file and run cc-backend --migrate-db", v, Version) os.Exit(0) } - if v > supportedVersion { - log.Warnf("Unsupported database version %d, need %d.\nPlease refer to documentation how to downgrade db with external migrate tool!", v, supportedVersion) + if v > Version { + log.Warnf("Unsupported database version %d, need %d.\nPlease refer to documentation how to downgrade db with external migrate tool!", v, Version) os.Exit(0) } } diff --git a/pkg/archive/archive.go b/pkg/archive/archive.go index 3f39d31..6b0671b 100644 --- a/pkg/archive/archive.go +++ b/pkg/archive/archive.go @@ -13,10 +13,10 @@ import ( "github.com/ClusterCockpit/cc-backend/pkg/schema" ) -const Version = 1 +const Version uint64 = 1 type ArchiveBackend interface { - Init(rawConfig json.RawMessage) (int, error) + Init(rawConfig json.RawMessage) (uint64, error) LoadJobMeta(job *schema.Job) (*schema.JobMeta, error) diff --git a/pkg/archive/fsBackend.go b/pkg/archive/fsBackend.go index 847152b..71d21ea 100644 --- a/pkg/archive/fsBackend.go +++ b/pkg/archive/fsBackend.go @@ -101,7 +101,7 @@ func loadJobData(filename string, isCompressed bool) (schema.JobData, error) { } } -func (fsa *FsArchive) Init(rawConfig json.RawMessage) (int, error) { +func (fsa *FsArchive) Init(rawConfig json.RawMessage) (uint64, error) { var config FsArchiveConfig if err := json.Unmarshal(rawConfig, &config); err != nil { @@ -121,7 +121,7 @@ func (fsa *FsArchive) Init(rawConfig json.RawMessage) (int, error) { return 0, err } - version, err := strconv.Atoi(strings.TrimSuffix(string(b), "\n")) + version, err := strconv.ParseUint(strings.TrimSuffix(string(b), "\n"), 10, 64) if err != nil { log.Errorf("fsBackend Init()- %v", err) return 0, err