Merge pull request #305 from diogob/moves_minimum_pg_version_to_config
Moves minimum pg version to config
This commit is contained in:
@@ -8,15 +8,17 @@ It also can be used to define other middleware configuration that may be delegat
|
||||
external configuration.
|
||||
|
||||
It currently includes a hardcoded CORS policy but this could easly be turned in configurable behaviour if needed.
|
||||
|
||||
Other hardcoded options such as the minimum version number also belong here.
|
||||
-}
|
||||
module PostgREST.Config ( prettyVersion
|
||||
, readOptions
|
||||
, corsPolicy
|
||||
, minimumPgVersion
|
||||
, AppConfig (..)
|
||||
)
|
||||
where
|
||||
|
||||
|
||||
import Control.Applicative
|
||||
import qualified Data.ByteString.Char8 as BS
|
||||
import qualified Data.CaseInsensitive as CI
|
||||
@@ -100,3 +102,7 @@ readOptions = customExecParser parserPrefs opts
|
||||
<> " / create a REST API to an existing Postgres database"
|
||||
)
|
||||
parserPrefs = prefs showHelpOnError
|
||||
|
||||
-- | Tells the minimum PostgreSQL version required by this version of PostgREST
|
||||
minimumPgVersion :: Integer
|
||||
minimumPgVersion = 90200
|
||||
|
||||
@@ -26,12 +26,13 @@ import System.IO (BufferMode (..),
|
||||
|
||||
import PostgREST.Config (AppConfig (..),
|
||||
prettyVersion,
|
||||
readOptions)
|
||||
readOptions,
|
||||
minimumPgVersion)
|
||||
|
||||
isServerVersionSupported :: H.Session P.Postgres IO Bool
|
||||
isServerVersionSupported = do
|
||||
Identity (row :: Text) <- H.tx Nothing $ H.singleEx $ [H.stmt|SHOW server_version_num|]
|
||||
return $ read (cs row) >= (90200::Integer)
|
||||
return $ read (cs row) >= minimumPgVersion
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
|
||||
Reference in New Issue
Block a user