Files
wehub-resource-sync 75f3dd141c
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CI and Release / lint-frontend (push) Has been cancelled
CI and Release / dockerfile-scan (push) Has been cancelled
CI and Release / test-frontend (push) Has been cancelled
CI and Release / lint-verification-agent (push) Has been cancelled
CI and Release / test-verification-agent (push) Has been cancelled
CI and Release / e2e-verification-agent (push) Has been cancelled
CI and Release / test-backend (push) Has been cancelled
CI and Release / build-dev-image (push) Has been cancelled
CI and Release / push-dev-image (push) Has been cancelled
CI and Release / build-image (push) Has been cancelled
CI and Release / build-verification-image (push) Has been cancelled
CI and Release / determine-version (push) Has been cancelled
CI and Release / push-image (push) Has been cancelled
CI and Release / push-verification-image (12) (push) Has been cancelled
CI and Release / lint-backend (push) Has been cancelled
CI and Release / push-verification-image (17) (push) Has been cancelled
CI and Release / push-verification-image (18) (push) Has been cancelled
CI and Release / release (push) Has been cancelled
CI and Release / publish-helm-chart (push) Has been cancelled
CI and Release / push-verification-image (13) (push) Has been cancelled
CI and Release / push-verification-image (14) (push) Has been cancelled
CI and Release / push-verification-image (15) (push) Has been cancelled
CI and Release / push-verification-image (16) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:11:07 +08:00

73 lines
1.8 KiB
Go

package tools
import (
"fmt"
"strconv"
)
type PostgresqlExtension string
const (
// needed for queries monitoring
PostgresqlExtensionPgStatMonitor PostgresqlExtension = "pg_stat_statements"
)
type PostgresqlVersion string
const (
PostgresqlVersion12 PostgresqlVersion = "12"
PostgresqlVersion13 PostgresqlVersion = "13"
PostgresqlVersion14 PostgresqlVersion = "14"
PostgresqlVersion15 PostgresqlVersion = "15"
PostgresqlVersion16 PostgresqlVersion = "16"
PostgresqlVersion17 PostgresqlVersion = "17"
PostgresqlVersion18 PostgresqlVersion = "18"
)
type PostgresqlExecutable string
const (
PostgresqlExecutablePgDump PostgresqlExecutable = "pg_dump"
PostgresqlExecutablePsql PostgresqlExecutable = "psql"
PostgresqlExecutablePgBasebackup PostgresqlExecutable = "pg_basebackup"
PostgresqlExecutablePgReceivewal PostgresqlExecutable = "pg_receivewal"
PostgresqlExecutablePgCombinebackup PostgresqlExecutable = "pg_combinebackup"
)
func GetPostgresqlVersionEnum(version string) PostgresqlVersion {
switch version {
case "12":
return PostgresqlVersion12
case "13":
return PostgresqlVersion13
case "14":
return PostgresqlVersion14
case "15":
return PostgresqlVersion15
case "16":
return PostgresqlVersion16
case "17":
return PostgresqlVersion17
case "18":
return PostgresqlVersion18
default:
panic(fmt.Sprintf("invalid postgresql version: %s", version))
}
}
func IsBackupDbVersionHigherThanRestoreDbVersion(
backupDbVersion, restoreDbVersion PostgresqlVersion,
) bool {
backupDbVersionInt, err := strconv.Atoi(string(backupDbVersion))
if err != nil {
return false
}
restoreDbVersionInt, err := strconv.Atoi(string(restoreDbVersion))
if err != nil {
return false
}
return backupDbVersionInt > restoreDbVersionInt
}