Last active
July 26, 2024 09:52
-
-
Save elalemanyo/98dd09b081d7fc688b3059ee2494f595 to your computer and use it in GitHub Desktop.
Check rails postgres version
This file contains hidden or 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
10.6 |
This file contains hidden or 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
def check_postgres_version | |
postgres_expected_version = `cat .postgres-version`.strip | |
postgres_version = ActiveRecord::Base.connection.select_value("SELECT VERSION()").match(/[0-9]{1,2}([,.][0-9]{1,2})?/)[0] | |
unless postgres_version.index(postgres_expected_version) | |
abort("\e[31mInvalid PostgreSQL version. Please use '#{postgres_expected_version}', found '#{postgres_version}'\e[0m") | |
end | |
end | |
check_postgres_version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment