Set all versions and print in version flag

This commit is contained in:
Jan Eitzinger
2023-04-12 10:43:46 +02:00
parent 9ea0d6c8d1
commit 10f4e09562
6 changed files with 13 additions and 11 deletions

View File

@@ -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

View File

@@ -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)
}
}