mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix(cli): Fix postgres TDE failing version check (#7203)
This commit is contained in:
+7
-7
@@ -1740,24 +1740,24 @@ func connectToPostgres(ctx context.Context, logger slog.Logger, driver string, d
|
||||
}
|
||||
|
||||
// Ensure the PostgreSQL version is >=13.0.0!
|
||||
version, err := sqlDB.QueryContext(ctx, "SHOW server_version;")
|
||||
version, err := sqlDB.QueryContext(ctx, "SHOW server_version_num;")
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("get postgres version: %w", err)
|
||||
}
|
||||
if !version.Next() {
|
||||
return nil, xerrors.Errorf("no rows returned for version select")
|
||||
}
|
||||
var versionStr string
|
||||
err = version.Scan(&versionStr)
|
||||
var versionNum int
|
||||
err = version.Scan(&versionNum)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("scan version: %w", err)
|
||||
}
|
||||
_ = version.Close()
|
||||
versionStr = strings.Split(versionStr, " ")[0]
|
||||
if semver.Compare("v"+versionStr, "v13") < 0 {
|
||||
return nil, xerrors.New("PostgreSQL version must be v13.0.0 or higher!")
|
||||
|
||||
if versionNum < 130000 {
|
||||
return nil, xerrors.Errorf("PostgreSQL version must be v13.0.0 or higher! Got: %d", versionNum)
|
||||
}
|
||||
logger.Debug(ctx, "connected to postgresql", slog.F("version", versionStr))
|
||||
logger.Debug(ctx, "connected to postgresql", slog.F("version", versionNum))
|
||||
|
||||
err = migrations.Up(sqlDB)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user