refactor: move DbStructure.PgVersion to Config
Now that PgVersion is not part of DbStructure, Config is a more apt module for it. Also rename getDbStructure to queryDbStructure. AppState also had a getDbStructure function for a record field.
This commit is contained in:
committed by
Steve Chavez
parent
823348a72a
commit
f169661ce6
+10
-11
@@ -17,14 +17,13 @@ import Control.Retry (RetryStatus, capDelay, exponentialBackoff,
|
||||
retrying, rsPreviousDelay)
|
||||
import Data.Text.IO (hPutStrLn)
|
||||
|
||||
import PostgREST.AppState (AppState)
|
||||
import PostgREST.Config (AppConfig (..), readAppConfig)
|
||||
import PostgREST.Config.Database (loadDbSettings)
|
||||
import PostgREST.DbStructure (getDbStructure, getPgVersion)
|
||||
import PostgREST.DbStructure.PgVersion (PgVersion (..),
|
||||
minimumPgVersion)
|
||||
import PostgREST.Error (PgError (PgError),
|
||||
checkIsFatal, errorPayload)
|
||||
import PostgREST.AppState (AppState)
|
||||
import PostgREST.Config (AppConfig (..), readAppConfig)
|
||||
import PostgREST.Config.Database (queryDbSettings, queryPgVersion)
|
||||
import PostgREST.Config.PgVersion (PgVersion (..), minimumPgVersion)
|
||||
import PostgREST.DbStructure (queryDbStructure)
|
||||
import PostgREST.Error (PgError (PgError), checkIsFatal,
|
||||
errorPayload)
|
||||
|
||||
import qualified PostgREST.AppState as AppState
|
||||
|
||||
@@ -117,7 +116,7 @@ connectionStatus pool =
|
||||
|
||||
getConnectionStatus :: IO ConnectionStatus
|
||||
getConnectionStatus = do
|
||||
pgVersion <- P.use pool getPgVersion
|
||||
pgVersion <- P.use pool queryPgVersion
|
||||
case pgVersion of
|
||||
Left e -> do
|
||||
let err = PgError False e
|
||||
@@ -152,7 +151,7 @@ loadSchemaCache appState = do
|
||||
AppConfig{..} <- AppState.getConfig appState
|
||||
result <-
|
||||
P.use (AppState.getPool appState) . HT.transaction HT.ReadCommitted HT.Read $
|
||||
getDbStructure (toList configDbSchemas) configDbExtraSearchPath configDbPreparedStatements
|
||||
queryDbStructure (toList configDbSchemas) configDbExtraSearchPath configDbPreparedStatements
|
||||
case result of
|
||||
Left e -> do
|
||||
let
|
||||
@@ -227,7 +226,7 @@ reReadConfig startingUp appState = do
|
||||
AppConfig{..} <- AppState.getConfig appState
|
||||
dbSettings <-
|
||||
if configDbConfig then
|
||||
loadDbSettings (AppState.getPool appState)
|
||||
queryDbSettings (AppState.getPool appState)
|
||||
else
|
||||
pure mempty
|
||||
readAppConfig dbSettings configFilePath (Just configDbUri) >>= \case
|
||||
|
||||
Reference in New Issue
Block a user