-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1010 from berkeli/feat-error-for-unsupported-psql…
…-versions feat: error for unsupported psql versions
- Loading branch information
Showing
3 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package utils | ||
|
||
import ( | ||
"database/sql" | ||
"fmt" | ||
) | ||
|
||
const ( | ||
// The earliest supported version of PostgreSQL is 13.8 | ||
earliestPostgresVersion = 130008 | ||
) | ||
|
||
// EnsureDBVersion checks the version of the given database connection and returns an error if the version is not | ||
// supported. | ||
func EnsureDBVersion(db *sql.DB) (version int, err error) { | ||
err = db.QueryRow("SHOW server_version_num;").Scan(&version) | ||
if err != nil { | ||
return | ||
} | ||
if version < earliestPostgresVersion { | ||
err = fmt.Errorf("unsupported postgres version: %d, expected >= %d", version, earliestPostgresVersion) | ||
} | ||
return | ||
} |