Merge pull request #305 from diogob/moves_minimum_pg_version_to_config

Moves minimum pg version to config
This commit is contained in:
Joe Nelson
2015-10-06 17:58:18 -07:00
2 changed files with 10 additions and 3 deletions
+7 -1
View File
@@ -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
+3 -2
View File
@@ -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