EnsureDBVersion checks the version of the given database connection and returns an error if the version is not supported.
(db *pgxpool.Pool)
| 212 | // EnsureDBVersion checks the version of the given database connection |
| 213 | // and returns an error if the version is not supported. |
| 214 | func EnsureDBVersion(db *pgxpool.Pool) (version string, err error) { |
| 215 | err = db.QueryRow(context.Background(), "SHOW server_version_num;").Scan(&version) |
| 216 | if err != nil { |
| 217 | return version, err |
| 218 | } |
| 219 | v, err := strconv.Atoi(version) |
| 220 | if v < earliestPostgresVersion { |
| 221 | err = fmt.Errorf("unsupported postgres version: %s, expected >= %d", version, earliestPostgresVersion) |
| 222 | } |
| 223 | return version, err |
| 224 | } |
no test coverage detected