-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Start and stop a temporary postgres -- -- Start and stop a temporary postgres. See README.md @package tmp-postgres @version 1.13.1.2 -- | This module provides the low level functionality for running -- initdb, postgres and createdb to make a -- database. -- -- See startPlan for more details. module Database.Postgres.Temp.Internal.Core -- | Internal events for debugging data Event -- | The first event. This useful for debugging what is actual passed to -- the initdb, createdb and postgres. StartPlan :: String -> Event -- | The second event. Postgres is about to get called StartPostgres :: Event -- | The third event. Postgres started. We are now about to setup a -- reconnect loop (racing with a process checker) WaitForDB :: Event -- | The fourth event and (possibly all subsequent events). We are looping -- trying to successfully connect to the postgres process. TryToConnect :: Event -- | A list of failures that can occur when starting. This is not and -- exhaustive list but covers the errors that the system catches for the -- user. data StartError -- | postgres failed before a connection succeeded. Most likely -- this is due to invalid configuration StartPostgresFailed :: ExitCode -> StartError -- | initdb failed. This can be from invalid configuration or -- using a non-empty data directory InitDbFailed :: String -> String -> ExitCode -> StartError [startErrorStdOut] :: StartError -> String [startErrorStdErr] :: StartError -> String [startErrorExitCode] :: StartError -> ExitCode -- | createdb failed. This can be from invalid configuration or -- the database might already exist. CreateDbFailed :: String -> String -> ExitCode -> StartError [startErrorStdOut] :: StartError -> String [startErrorStdErr] :: StartError -> String [startErrorExitCode] :: StartError -> ExitCode -- | The Plan was missing info and a complete CompletePlan -- could not be created. CompletePlanFailed :: String -> [String] -> StartError -- | The ProcessConfig was missing info and a -- CompleteProcessConfig could not be created. CompleteProcessConfigFailed :: String -> [String] -> StartError -- | Timed out waiting for postgres to accept a connection ConnectionTimedOut :: StartError DeleteDbError :: SqlError -> StartError -- | A way to log internal Events type Logger = Event -> IO () -- | postgres is not ready until we are able to successfully -- connect. waitForDB attempts to connect over and over again and -- returns after the first successful connection. waitForDB :: Logger -> Options -> IO () -- | CompleteProcessConfig contains the configuration necessary for -- starting a process. It is essentially a stripped down -- CreateProcess. data CompleteProcessConfig CompleteProcessConfig :: [(String, String)] -> [String] -> Handle -> Handle -> Handle -> CompleteProcessConfig -- | Environment variables [completeProcessConfigEnvVars] :: CompleteProcessConfig -> [(String, String)] -- | Command line arguements [completeProcessConfigCmdLine] :: CompleteProcessConfig -> [String] -- | The Handle for standard input [completeProcessConfigStdIn] :: CompleteProcessConfig -> Handle -- | The Handle for standard output [completeProcessConfigStdOut] :: CompleteProcessConfig -> Handle -- | The Handle for standard error [completeProcessConfigStdErr] :: CompleteProcessConfig -> Handle -- | Start a process interactively and return the ProcessHandle startProcess :: String -> CompleteProcessConfig -> IO ProcessHandle -- | Stop a ProcessHandle. An alias for waitForProcess stopProcess :: ProcessHandle -> IO ExitCode -- | Start a process and block until it finishes return the -- ExitCode. executeProcess :: String -> CompleteProcessConfig -> IO ExitCode -- | Start a process and block until it finishes return the ExitCode -- and the stderr output. executeProcessAndTee :: String -> CompleteProcessConfig -> IO (ExitCode, String, String) -- | CompletePostgresPlan is used be startPostgresProcess to -- start the postgres and then attempt to connect to it. data CompletePostgresPlan CompletePostgresPlan :: CompleteProcessConfig -> Options -> CompletePostgresPlan -- | The process config for postgres [completePostgresPlanProcessConfig] :: CompletePostgresPlan -> CompleteProcessConfig -- | Connection options. Used to verify that postgres is ready. [completePostgresPlanClientOptions] :: CompletePostgresPlan -> Options -- | The output of calling startPostgresProcess. data PostgresProcess PostgresProcess :: Options -> ProcessHandle -> PostgresProcess -- | Connection options [postgresProcessClientOptions] :: PostgresProcess -> Options -- | postgres process handle [postgresProcessHandle] :: PostgresProcess -> ProcessHandle -- | Stop the postgres process after attempting to terminate all -- the connections. stopPostgresProcess :: PostgresProcess -> IO ExitCode -- | Start the postgres process and block until a successful -- connection occurs. A separate thread we continously check to see if -- the postgres process has crashed. startPostgresProcess :: Int -> Logger -> CompletePostgresPlan -> IO PostgresProcess -- | CompletePlan is the low level configuration necessary for -- creating a database starting postgres and creating a -- database. There is no validation done on the CompletePlan. It -- is recommend that one use the higher level functions such as -- start which will generate plans that are valid. -- CompletePlans are used internally but are exposed if the higher -- level plan generation is not sufficent. data CompletePlan CompletePlan :: Logger -> Maybe CompleteProcessConfig -> Maybe CompleteProcessConfig -> CompletePostgresPlan -> String -> FilePath -> Int -> CompletePlan [completePlanLogger] :: CompletePlan -> Logger [completePlanInitDb] :: CompletePlan -> Maybe CompleteProcessConfig [completePlanCreateDb] :: CompletePlan -> Maybe CompleteProcessConfig [completePlanPostgres] :: CompletePlan -> CompletePostgresPlan [completePlanConfig] :: CompletePlan -> String [completePlanDataDirectory] :: CompletePlan -> FilePath [completePlanConnectionTimeout] :: CompletePlan -> Int -- | Call createdb and tee the output to return if there is an an -- exception. Throws CreateDbFailed. executeCreateDb :: CompleteProcessConfig -> IO () -- | startPlan optionally calls initdb, optionally calls -- createdb and unconditionally calls postgres. -- Additionally it writes a "postgresql.conf" and does not return until -- the postgres process is ready. See -- startPostgresProcess for more details. startPlan :: CompletePlan -> IO PostgresProcess -- | Stop the postgres process. See stopPostgresProcess for -- more details. stopPlan :: PostgresProcess -> IO ExitCode instance GHC.Classes.Eq Database.Postgres.Temp.Internal.Core.StartError instance GHC.Show.Show Database.Postgres.Temp.Internal.Core.StartError instance GHC.Classes.Ord Database.Postgres.Temp.Internal.Core.Event instance GHC.Classes.Eq Database.Postgres.Temp.Internal.Core.Event instance GHC.Show.Show Database.Postgres.Temp.Internal.Core.Event instance Text.PrettyPrint.ANSI.Leijen.Internal.Pretty Database.Postgres.Temp.Internal.Core.CompletePlan instance Text.PrettyPrint.ANSI.Leijen.Internal.Pretty Database.Postgres.Temp.Internal.Core.PostgresProcess instance Text.PrettyPrint.ANSI.Leijen.Internal.Pretty Database.Postgres.Temp.Internal.Core.CompletePostgresPlan instance Text.PrettyPrint.ANSI.Leijen.Internal.Pretty Database.Postgres.Temp.Internal.Core.CompleteProcessConfig instance GHC.Exception.Type.Exception Database.Postgres.Temp.Internal.Core.StartError -- | This module provides types and functions for combining partial configs -- into a complete configs to ultimately make a CompletePlan. -- -- This module has two classes of types. -- -- Types like ProcessConfig that could be used by any library that -- needs to combine process options. -- -- Finally it has types and functions for creating CompletePlans -- that use temporary resources. This is used to create the default -- behavior of startConfig and related functions. | module Database.Postgres.Temp.Internal.Config -- | The environment variables can be declared to inherit from the running -- process or they can be specifically added. data EnvironmentVariables EnvironmentVariables :: Last Bool -> Map String String -> EnvironmentVariables [inherit] :: EnvironmentVariables -> Last Bool [specific] :: EnvironmentVariables -> Map String String -- | Combine the current environment (if indicated by inherit) with -- specific. completeEnvironmentVariables :: [(String, String)] -> EnvironmentVariables -> Either [String] [(String, String)] -- | A type to help combine command line Args. data CommandLineArgs CommandLineArgs :: Map String (Maybe String) -> Map Int String -> CommandLineArgs -- | Args of the form -h foo, --host=foo and -- --switch. The key is mappended with value so the key -- should include the space or equals (as shown in the first two examples -- respectively). The Dual monoid is used so the last key wins. [keyBased] :: CommandLineArgs -> Map String (Maybe String) -- | Args that appear at the end of the key based Args. The Dual -- monoid is used so the last key wins. [indexBased] :: CommandLineArgs -> Map Int String -- | This convert the CommandLineArgs to '[String]'. completeCommandLineArgs :: CommandLineArgs -> [String] -- | Process configuration data ProcessConfig ProcessConfig :: EnvironmentVariables -> CommandLineArgs -> Last Handle -> Last Handle -> Last Handle -> ProcessConfig -- | A monoid for combine environment variables or replacing them. for the -- maps the Dual monoid is used. So the last key wins. [environmentVariables] :: ProcessConfig -> EnvironmentVariables -- | A monoid for combine command line Args or replacing them. [commandLine] :: ProcessConfig -> CommandLineArgs -- | A monoid for configuring the standard input Handle. [stdIn] :: ProcessConfig -> Last Handle -- | A monoid for configuring the standard output Handle. [stdOut] :: ProcessConfig -> Last Handle -- | A monoid for configuring the standard error Handle. [stdErr] :: ProcessConfig -> Last Handle -- | The standardProcessConfig sets the handles to stdin, -- stdout and stderr and inherits the environment variables -- from the calling process. standardProcessConfig :: ProcessConfig -- | A global reference to devnull Handle. devNull :: Handle -- | silentProcessConfig sets the handles to devnull -- and inherits the environment variables from the calling process. silentProcessConfig :: ProcessConfig -- | Turn a ProcessConfig into a ProcessConfig. Fails if any -- values are missing. completeProcessConfig :: [(String, String)] -> ProcessConfig -> Either [String] CompleteProcessConfig -- | A type to track whether a file is temporary and needs to be cleaned -- up. data CompleteDirectoryType CPermanent :: FilePath -> CompleteDirectoryType CTemporary :: FilePath -> CompleteDirectoryType -- | Get the file path of a CompleteDirectoryType, regardless if it -- is a CPermanent or CTemporary type. toFilePath :: CompleteDirectoryType -> FilePath -- | Used to specify a Temporary folder that is automatically -- cleaned up or a Permanent folder which is not automatically -- cleaned up. data DirectoryType -- | A permanent file that should not be generated. Permanent :: FilePath -> DirectoryType -- | A temporary file that needs to generated. Temporary :: DirectoryType -- | Either create aCTemporary directory or do nothing to a -- CPermanent one. setupDirectoryType :: String -> String -> DirectoryType -> IO CompleteDirectoryType -- | Either remove a CTemporary directory or do nothing to a -- CPermanent one. cleanupDirectoryType :: CompleteDirectoryType -> IO () -- | A type for configuring the listening address of the postgres -- process. postgres can listen on several types of sockets -- simulatanously but we don't support that behavior. One can either -- listen on a IP based socket or a UNIX domain socket. data CompleteSocketClass -- | IP socket type. The String is either an IP address or a host -- that will resolve to an IP address. CIpSocket :: String -> CompleteSocketClass -- | UNIX domain socket CUnixSocket :: CompleteDirectoryType -> CompleteSocketClass -- | Create the extra config lines for listening based on the -- CompleteSocketClass. socketClassToConfig :: CompleteSocketClass -> [String] -- | Many processes require a "host" flag. We can generate one from the -- CompleteSocketClass. socketClassToHostFlag :: CompleteSocketClass -> [(String, Maybe String)] -- | Get the IP address, host name or UNIX domain socket directory as a -- String. socketClassToHost :: CompleteSocketClass -> String -- | SocketClass is used to specify how postgres should -- listen for connections The two main options are a IpSocket -- which takes a hostname or IP address. if not is given the default it -- "127.0.0.1". Alternatively one can specify UnixSocket for a -- UNIX domain socket. If a directory is specified the socket will live -- in that folder. Otherwise a temporary folder will get created for the -- socket. data SocketClass -- | The monoid for combining IP address configuration. IpSocket :: Last String -> SocketClass -- | The monoid for combining UNIX socket configuration. UnixSocket :: DirectoryType -> SocketClass -- | Turn a SocketClass to a CompleteSocketClass. If the -- IpSocket is Nothing default to "127.0.0.1". If the is a -- UnixSocket optionally create a temporary directory if -- configured to do so. setupSocketClass :: String -> SocketClass -> IO CompleteSocketClass -- | Cleanup the UNIX socket temporary directory if one was created. cleanupSocketConfig :: CompleteSocketClass -> IO () -- | postgres process config and corresponding client connection -- Options. data PostgresPlan PostgresPlan :: ProcessConfig -> Options -> PostgresPlan -- | Monoid for the postgres ProcessConfig. [postgresConfig] :: PostgresPlan -> ProcessConfig -- | Monoid for the postgres client connection options. [connectionOptions] :: PostgresPlan -> Options -- | Turn a PostgresPlan into a CompletePostgresPlan. Fails -- if any values are missing. completePostgresPlan :: [(String, String)] -> PostgresPlan -> Either [String] CompletePostgresPlan -- | Describe how to run initdb, createdb and -- postgres data Plan Plan :: Last Logger -> Maybe ProcessConfig -> Maybe ProcessConfig -> PostgresPlan -> [String] -> Last String -> Last Int -> Plan [logger] :: Plan -> Last Logger [initDbConfig] :: Plan -> Maybe ProcessConfig [createDbConfig] :: Plan -> Maybe ProcessConfig [postgresPlan] :: Plan -> PostgresPlan [postgresConfigFile] :: Plan -> [String] [dataDirectoryString] :: Plan -> Last String -- | Max time to spend attempting to connection to postgres. Time -- is in microseconds. [connectionTimeout] :: Plan -> Last Int -- | Turn a Plan into a CompletePlan. Fails if any values are -- missing. completePlan :: [(String, String)] -> Plan -> Either [String] CompletePlan -- | The high level options for overriding default behavior. data Config Config :: Plan -> SocketClass -> DirectoryType -> Last (Maybe Int) -> Last FilePath -> Config -- | Extend or replace any of the configuration used to create a final -- CompletePlan. [plan] :: Config -> Plan -- | Override the default CompleteSocketClass by setting this. [socketClass] :: Config -> SocketClass -- | Override the default temporary data directory by passing in -- Permanent DIRECTORY. [dataDirectory] :: Config -> DirectoryType -- | A monoid for using an existing port (via Just -- PORT_NUMBER) or requesting a free port (via a -- Nothing). [port] :: Config -> Last (Maybe Int) -- | The directory used to create other temporary directories. Defaults to -- /tmp. [temporaryDirectory] :: Config -> Last FilePath -- | Create a Plan that sets the command line options of all -- processes (initdb, postgres and createdb). -- This the generated plan that is combined with the -- extra plan from startConfig. toPlan :: Bool -> Bool -> Int -> CompleteSocketClass -> FilePath -> Plan -- | Create all the temporary resources from a Config. This also -- combines the Plan from toPlan with the extra -- Config passed in. setupConfig :: Config -> IO Resources -- | Free the temporary resources created by setupConfig. cleanupConfig :: Resources -> IO () -- | Display a Config. prettyPrintConfig :: Config -> String -- | Resources holds a description of the temporary folders (if -- there are any) and includes the final CompletePlan that can be -- used with startPlan. See setupConfig for an example of -- how to create a Resources. data Resources Resources :: CompletePlan -> CompleteSocketClass -> CompleteDirectoryType -> FilePath -> Resources -- | Final CompletePlan. See startPlan for information on -- CompletePlans. [resourcesPlan] :: Resources -> CompletePlan -- | The CompleteSocketClass. Used to track if a temporary directory -- was made as the socket location. [resourcesSocket] :: Resources -> CompleteSocketClass -- | The data directory. Used to track if a temporary directory was used. [resourcesDataDir] :: Resources -> CompleteDirectoryType -- | The directory where other temporary directories are created. Usually -- @/tmp. [resourcesTemporaryDir] :: Resources -> FilePath -- | Make the resourcesDataDir CPermanent so it will not get -- cleaned up. makeResourcesDataDirPermanent :: Resources -> Resources -- | Attempt to create a config from a Options. This is useful if -- want to create a database owned by a specific user you will also log -- in as among other use cases. It is possible some Options are -- not supported so don't hesitate to open an issue on github if you find -- one. optionsToConfig :: Options -> Config -- | Local Lens alias. type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t -- | Local Lens' alias. type Lens' s a = Lens s s a a -- | Lens for inherit inheritL :: Lens' EnvironmentVariables (Last Bool) -- | Lens for specific. specificL :: Lens' EnvironmentVariables (Map String String) -- | Lens for commandLine. commandLineL :: Lens' ProcessConfig CommandLineArgs -- | Lens for environmentVariables. environmentVariablesL :: Lens' ProcessConfig EnvironmentVariables -- | Lens for stdErr stdErrL :: Lens' ProcessConfig (Last Handle) -- | Lens for stdIn. stdInL :: Lens' ProcessConfig (Last Handle) -- | Lens for stdOut. stdOutL :: Lens' ProcessConfig (Last Handle) -- | Lens for connectionOptions. connectionOptionsL :: Lens' PostgresPlan Options -- | Lens for postgresConfig. postgresConfigL :: Lens' PostgresPlan ProcessConfig -- | Lens for postgresConfigFile. postgresConfigFileL :: Lens' Plan [String] -- | Lens for createDbConfig. createDbConfigL :: Lens' Plan (Maybe ProcessConfig) -- | Lens for dataDirectoryString. dataDirectoryStringL :: Lens' Plan (Last String) -- | Lens for initDbConfig. initDbConfigL :: Lens' Plan (Maybe ProcessConfig) -- | Lens for logger. loggerL :: Lens' Plan (Last Logger) -- | Lens for postgresPlan. postgresPlanL :: Lens' Plan PostgresPlan -- | Lens for connectionTimeout. connectionTimeoutL :: Lens' Plan (Last Int) -- | Lens for resourcesDataDir. resourcesDataDirL :: Lens' Resources CompleteDirectoryType -- | Lens for resourcesPlan. resourcesPlanL :: Lens' Resources CompletePlan -- | Lens for resourcesSocket. resourcesSocketL :: Lens' Resources CompleteSocketClass -- | Lens for dataDirectory. dataDirectoryL :: Lens' Config DirectoryType -- | Lens for plan. planL :: Lens' Config Plan -- | Lens for port. portL :: Lens' Config (Last (Maybe Int)) -- | Lens for socketClass. socketClassL :: Lens' Config SocketClass -- | Lens for socketClass. temporaryDirectoryL :: Lens' Config (Last FilePath) -- | Lens for indexBased. indexBasedL :: Lens' CommandLineArgs (Map Int String) -- | Lens for keyBased. keyBasedL :: Lens' CommandLineArgs (Map String (Maybe String)) instance GHC.Base.Monoid Database.Postgres.Temp.Internal.Config.Config instance GHC.Base.Semigroup Database.Postgres.Temp.Internal.Config.Config instance GHC.Generics.Generic Database.Postgres.Temp.Internal.Config.Config instance GHC.Base.Monoid Database.Postgres.Temp.Internal.Config.Plan instance GHC.Base.Semigroup Database.Postgres.Temp.Internal.Config.Plan instance GHC.Generics.Generic Database.Postgres.Temp.Internal.Config.Plan instance GHC.Base.Monoid Database.Postgres.Temp.Internal.Config.PostgresPlan instance GHC.Base.Semigroup Database.Postgres.Temp.Internal.Config.PostgresPlan instance GHC.Generics.Generic Database.Postgres.Temp.Internal.Config.PostgresPlan instance GHC.Generics.Generic Database.Postgres.Temp.Internal.Config.SocketClass instance GHC.Classes.Ord Database.Postgres.Temp.Internal.Config.SocketClass instance GHC.Classes.Eq Database.Postgres.Temp.Internal.Config.SocketClass instance GHC.Show.Show Database.Postgres.Temp.Internal.Config.SocketClass instance GHC.Generics.Generic Database.Postgres.Temp.Internal.Config.CompleteSocketClass instance GHC.Classes.Ord Database.Postgres.Temp.Internal.Config.CompleteSocketClass instance GHC.Classes.Eq Database.Postgres.Temp.Internal.Config.CompleteSocketClass instance GHC.Show.Show Database.Postgres.Temp.Internal.Config.CompleteSocketClass instance GHC.Classes.Ord Database.Postgres.Temp.Internal.Config.DirectoryType instance GHC.Classes.Eq Database.Postgres.Temp.Internal.Config.DirectoryType instance GHC.Show.Show Database.Postgres.Temp.Internal.Config.DirectoryType instance GHC.Classes.Ord Database.Postgres.Temp.Internal.Config.CompleteDirectoryType instance GHC.Classes.Eq Database.Postgres.Temp.Internal.Config.CompleteDirectoryType instance GHC.Show.Show Database.Postgres.Temp.Internal.Config.CompleteDirectoryType instance GHC.Base.Monoid Database.Postgres.Temp.Internal.Config.ProcessConfig instance GHC.Base.Semigroup Database.Postgres.Temp.Internal.Config.ProcessConfig instance GHC.Show.Show Database.Postgres.Temp.Internal.Config.ProcessConfig instance GHC.Classes.Eq Database.Postgres.Temp.Internal.Config.ProcessConfig instance GHC.Generics.Generic Database.Postgres.Temp.Internal.Config.ProcessConfig instance GHC.Base.Monoid Database.Postgres.Temp.Internal.Config.CommandLineArgs instance GHC.Classes.Eq Database.Postgres.Temp.Internal.Config.CommandLineArgs instance GHC.Show.Show Database.Postgres.Temp.Internal.Config.CommandLineArgs instance GHC.Generics.Generic Database.Postgres.Temp.Internal.Config.CommandLineArgs instance GHC.Classes.Eq Database.Postgres.Temp.Internal.Config.EnvironmentVariables instance GHC.Show.Show Database.Postgres.Temp.Internal.Config.EnvironmentVariables instance GHC.Generics.Generic Database.Postgres.Temp.Internal.Config.EnvironmentVariables instance Text.PrettyPrint.ANSI.Leijen.Internal.Pretty Database.Postgres.Temp.Internal.Config.Resources instance Text.PrettyPrint.ANSI.Leijen.Internal.Pretty Database.Postgres.Temp.Internal.Config.Config instance Text.PrettyPrint.ANSI.Leijen.Internal.Pretty Database.Postgres.Temp.Internal.Config.Plan instance Text.PrettyPrint.ANSI.Leijen.Internal.Pretty Database.Postgres.Temp.Internal.Config.PostgresPlan instance Text.PrettyPrint.ANSI.Leijen.Internal.Pretty Database.Postgres.Temp.Internal.Config.SocketClass instance GHC.Base.Semigroup Database.Postgres.Temp.Internal.Config.SocketClass instance GHC.Base.Monoid Database.Postgres.Temp.Internal.Config.SocketClass instance Text.PrettyPrint.ANSI.Leijen.Internal.Pretty Database.Postgres.Temp.Internal.Config.CompleteSocketClass instance Text.PrettyPrint.ANSI.Leijen.Internal.Pretty Database.Postgres.Temp.Internal.Config.DirectoryType instance GHC.Base.Semigroup Database.Postgres.Temp.Internal.Config.DirectoryType instance GHC.Base.Monoid Database.Postgres.Temp.Internal.Config.DirectoryType instance Text.PrettyPrint.ANSI.Leijen.Internal.Pretty Database.Postgres.Temp.Internal.Config.CompleteDirectoryType instance Text.PrettyPrint.ANSI.Leijen.Internal.Pretty Database.Postgres.Temp.Internal.Config.ProcessConfig instance GHC.Base.Semigroup Database.Postgres.Temp.Internal.Config.CommandLineArgs instance Text.PrettyPrint.ANSI.Leijen.Internal.Pretty Database.Postgres.Temp.Internal.Config.CommandLineArgs instance GHC.Base.Semigroup Database.Postgres.Temp.Internal.Config.EnvironmentVariables instance GHC.Base.Monoid Database.Postgres.Temp.Internal.Config.EnvironmentVariables instance Text.PrettyPrint.ANSI.Leijen.Internal.Pretty Database.Postgres.Temp.Internal.Config.EnvironmentVariables -- | This module provides the high level functions that are re-exported by -- Database.Postgres.Temp. Additionally it includes some -- identifiers that are used for testing but are not exported. module Database.Postgres.Temp.Internal -- | Handle for holding temporary resources, the postgres process -- handle and postgres connection information. The DB also -- includes the final plan used to start initdb, -- createdb and postgres. See toConnectionString -- or toConnectionOptions for converting a DB to postgresql -- connection string. data DB DB :: Resources -> PostgresProcess -> DB -- | Temporary resources and the final CompletePlan. [dbResources] :: DB -> Resources -- | postgres process handle and the connection options. [dbPostgresProcess] :: DB -> PostgresProcess -- | Convert a DB to a connection string. Alternatively one can -- access the Options using toConnectionOptions. toConnectionString :: DB -> ByteString -- | Convert a DB to a connection Options type. toConnectionOptions :: DB -> Options -- | Access the data directory. This was either generated or specified -- explicitly when creating the Config toDataDirectory :: DB -> FilePath -- | Make the data directory permanent. Useful for debugging. If you are -- using with or withConfig this function will not modify -- the DB that is passed for cleanup. You will need to setup your -- own bracket like -- --
--   bracket (fmap makeDataDirPermanent start) (either mempty stop)
--   
makeDataDirPermanent :: DB -> DB -- | Get the directory that is used to create other temporary directories toTemporaryDirectory :: DB -> FilePath -- | Default postgres options defaultPostgresConfig :: [String] -- | The default configuration. This will create a database called -- "postgres" via initdb (it's default behavior). It will create -- a temporary directory for the data and a temporary directory for a -- unix socket on a random port. Additionally it will use the following -- "postgresql.conf" which is optimized for performance. -- --
--   shared_buffers = 12MB
--   fsync = off
--   synchronous_commit = off
--   full_page_writes = off
--   log_min_duration_statement = 0
--   log_connections = on
--   log_disconnections = on
--   client_min_messages = ERROR
--   
-- -- defaultConfig also passes the --no-sync flag to -- initdb. -- -- If you would like to customize this behavior you can start with the -- defaultConfig and overwrite fields or combine a -- defaultConfig with another Config using <> -- (mappend). -- -- Alternatively you can eschew defaultConfig altogether, however -- your postgres might start and run faster if you use -- defaultConfig. -- -- The defaultConfig also disables the logging of internal -- Events. -- -- To append additional lines to "postgresql.conf" file create a custom -- Config like the following. -- --
--   custom = defaultConfig <> mempty
--     { plan = mempty
--       { postgresConfigFile =
--           [ "wal_level = replica"
--           , "archive_mode = on"
--           , "max_wal_senders = 2"
--           , "fsync = on"
--           , "synchronous_commit = on"
--           ]
--       }
--     }
--   
-- -- Or using the provided lenses and your favorite lens library: -- --
--   custom = defaultConfig & planL . postgresConfigFile <>~
--     [ "wal_level = replica"
--     , "archive_mode = on"
--     , "max_wal_senders = 2"
--     , "fsync = on"
--     , "synchronous_commit = on"
--     ]
--   
-- -- This is common enough there is defaultPostgresConf which is a -- helper to do this. -- -- As an alternative to using defaultConfig one could create a -- config from connections parameters using -- optionsToDefaultConfig. defaultConfig :: Config -- | mappend the defaultConfig with a Config that -- provides additional "postgresql.conf" lines. Equivalent to: -- --
--   defaultPostgresConf extra = defaultConfig <> mempty
--     { plan = mempty
--       { postgresConfigFile = extra
--       }
--     }
--   
-- -- or with lenses: -- --
--   defaultPostgresConf extra = defaultConfig & planL . postgresConfigFile <>~ extra
--   
defaultPostgresConf :: [String] -> Config -- | The same as defaultConfig but all the handles are set to -- devnull. See silentProcessConfig as well. silentConfig :: Config -- | Create zero or more temporary resources and use them to make a -- Config. -- -- The passed in config is inspected and a generated config is created. -- The final config is built by -- --
--   generated <> extra
--   
-- -- Based on the value of socketClass a "postgresql.conf" is -- created with: -- --
--   listen_addresses = 'IP_ADDRESS'
--   
-- -- if it is IpSocket. If is UnixSocket then the lines: -- --
--   listen_addresses = ''
--   unix_socket_directories = 'SOCKET_DIRECTORY'
--   
-- -- are added. -- -- Additionally the generated Config also does the -- following: -- -- -- -- All of these values can be overrided by the extra config. -- -- The returned DB requires cleanup. startConfig should be -- used with a bracket and stop, e.g. -- --
--   withConfig :: Config -> (DB -> IO a) -> IO (Either StartError a)
--   withConfig plan f = bracket (startConfig plan) (either mempty stop) $
--      either (pure . Left) (fmap Right . f)
--   
-- -- or just use withConfig. If you are calling startConfig -- you probably want withConfig anyway. startConfig :: Config -> IO (Either StartError DB) -- | Default start behavior. Equivalent to calling startConfig with -- the defaultConfig. start :: IO (Either StartError DB) -- | Stop the postgres process and cleanup any temporary resources -- that might have been created. stop :: DB -> IO () -- | Only stop the postgres process but leave any temporary -- resources. Useful for testing backup strategies when used in -- conjunction with restart or withRestart. stopPostgres :: DB -> IO ExitCode -- | Restart the postgres from DB using the prior -- Plan. restart :: DB -> IO (Either StartError DB) -- | Reload the configuration file without shutting down. Calls -- pg_reload_conf(). reloadConfig :: DB -> IO () -- | Exception safe database create with options. See startConfig -- for more details. Calls stop even in the face of exceptions. withConfig :: Config -> (DB -> IO a) -> IO (Either StartError a) -- | Default expectation safe interface. Equivalent to -- --
--   with = withConfig defaultConfig
--   
with :: (DB -> IO a) -> IO (Either StartError a) -- | Exception safe version of restart. withRestart :: DB -> (DB -> IO a) -> IO (Either StartError a) -- | Attempt to create a Config from a Options. Useful if you -- want to create a database owned by a specific user you will also login -- with among other use cases. optionsToDefaultConfig :: Options -> Config -- | Display a DB. prettyPrintDB :: DB -> String -- | Drop the db if it exists. Terminates all connections to the db first. dropDbIfExists :: Options -> String -> IO () -- | Use the current database as a template and make a copy. Give the copy -- a random name. -- -- Equivalent to: -- --
--   withNewDb = withNewDbConfig mempty
--   
-- -- See startNewDbConfig for more details. withNewDb :: DB -> (DB -> IO a) -> IO (Either StartError a) -- | Exception safe version of startNewDbConfig. Creates a temporary -- database using the current database as a template. -- -- See startNewDbConfig for more details. withNewDbConfig :: ProcessConfig -> DB -> (DB -> IO a) -> IO (Either StartError a) -- | Use the current database as a template and make a copy. Give the copy -- a random name. -- -- Equivalent to: -- --
--   startNewDb = startNewDbConfig mempty
--   
-- -- See startNewDbConfig for more details. startNewDb :: DB -> IO (Either StartError DB) -- | Use the current database as a template and make a copy. Give the copy -- a random name. -- -- Copying a database from a template can be faster than creating a new -- postgres and migrating a database from scratch. In artifical -- benchmarks it appears to be about 2x faster. -- -- To use the current database as a template all connections to the -- database must be terminated first. -- -- To override the arguments passed to createdb one can pass in -- extra ProcessConfig. The combined process is -- created by mappended the generated with the -- extra ProcessConfig, e.g. -- --
--   combined = generated <> extra
--   
-- -- The current implementation has a few known issues. -- -- If a connection is made between the termination command and the -- createdb call the createdb call will fail. -- -- Additionally the generated name is 32 character random name of -- characters "a" to "z". It is possible, although unlikeily that a -- duplicate database name could be generated and this would also cause a -- failure. -- -- startNewDbConfig requires cleanup so it best to use a -- bracket along with stopNewDb. This is equivalient to -- withNewDbConfig. -- -- The only reason to use startNewDbConfig over -- withNewDbConfig is if you are unable to use -- withNewDbConfig for some reason. startNewDbConfig :: ProcessConfig -> DB -> IO (Either StartError DB) -- | Cleanup the temporary database created by startNewDbConfig or -- startNewDb. stopNewDb :: DB -> IO () instance Text.PrettyPrint.ANSI.Leijen.Internal.Pretty Database.Postgres.Temp.Internal.DB -- | This module provides types and functions for combining partial configs -- into a complete configs to ultimately make a CompletePlan. -- -- This module has two classes of types. -- -- Types like ProcessConfig that could be used by any library that -- needs to combine process options. -- -- Finally it has types and functions for creating CompletePlans -- that use temporary resources. This is used to create the default -- behavior of startConfig and related functions. | module Database.Postgres.Temp.Config -- | The high level options for overriding default behavior. data Config Config :: Plan -> SocketClass -> DirectoryType -> Last (Maybe Int) -> Last FilePath -> Config -- | Extend or replace any of the configuration used to create a final -- CompletePlan. [plan] :: Config -> Plan -- | Override the default CompleteSocketClass by setting this. [socketClass] :: Config -> SocketClass -- | Override the default temporary data directory by passing in -- Permanent DIRECTORY. [dataDirectory] :: Config -> DirectoryType -- | A monoid for using an existing port (via Just -- PORT_NUMBER) or requesting a free port (via a -- Nothing). [port] :: Config -> Last (Maybe Int) -- | The directory used to create other temporary directories. Defaults to -- /tmp. [temporaryDirectory] :: Config -> Last FilePath -- | Display a Config. prettyPrintConfig :: Config -> String -- | Lens for plan. planL :: Lens' Config Plan -- | Lens for socketClass. socketClassL :: Lens' Config SocketClass -- | Lens for dataDirectory. dataDirectoryL :: Lens' Config DirectoryType -- | Lens for port. portL :: Lens' Config (Last (Maybe Int)) -- | Lens for connectionTimeout. connectionTimeoutL :: Lens' Plan (Last Int) -- | Describe how to run initdb, createdb and -- postgres data Plan Plan :: Last Logger -> Maybe ProcessConfig -> Maybe ProcessConfig -> PostgresPlan -> [String] -> Last String -> Last Int -> Plan [logger] :: Plan -> Last Logger [initDbConfig] :: Plan -> Maybe ProcessConfig [createDbConfig] :: Plan -> Maybe ProcessConfig [postgresPlan] :: Plan -> PostgresPlan [postgresConfigFile] :: Plan -> [String] [dataDirectoryString] :: Plan -> Last String -- | Max time to spend attempting to connection to postgres. Time -- is in microseconds. [connectionTimeout] :: Plan -> Last Int -- | Lens for postgresConfigFile. postgresConfigFileL :: Lens' Plan [String] -- | Lens for createDbConfig. createDbConfigL :: Lens' Plan (Maybe ProcessConfig) -- | Lens for dataDirectoryString. dataDirectoryStringL :: Lens' Plan (Last String) -- | Lens for initDbConfig. initDbConfigL :: Lens' Plan (Maybe ProcessConfig) -- | Lens for logger. loggerL :: Lens' Plan (Last Logger) -- | Lens for postgresPlan. postgresPlanL :: Lens' Plan PostgresPlan -- | postgres process config and corresponding client connection -- Options. data PostgresPlan PostgresPlan :: ProcessConfig -> Options -> PostgresPlan -- | Monoid for the postgres ProcessConfig. [postgresConfig] :: PostgresPlan -> ProcessConfig -- | Monoid for the postgres client connection options. [connectionOptions] :: PostgresPlan -> Options -- | Lens for connectionOptions. connectionOptionsL :: Lens' PostgresPlan Options -- | Lens for postgresConfig. postgresConfigL :: Lens' PostgresPlan ProcessConfig -- | Process configuration data ProcessConfig ProcessConfig :: EnvironmentVariables -> CommandLineArgs -> Last Handle -> Last Handle -> Last Handle -> ProcessConfig -- | A monoid for combine environment variables or replacing them. for the -- maps the Dual monoid is used. So the last key wins. [environmentVariables] :: ProcessConfig -> EnvironmentVariables -- | A monoid for combine command line Args or replacing them. [commandLine] :: ProcessConfig -> CommandLineArgs -- | A monoid for configuring the standard input Handle. [stdIn] :: ProcessConfig -> Last Handle -- | A monoid for configuring the standard output Handle. [stdOut] :: ProcessConfig -> Last Handle -- | A monoid for configuring the standard error Handle. [stdErr] :: ProcessConfig -> Last Handle -- | Lens for commandLine. commandLineL :: Lens' ProcessConfig CommandLineArgs -- | Lens for environmentVariables. environmentVariablesL :: Lens' ProcessConfig EnvironmentVariables -- | Lens for stdErr stdErrL :: Lens' ProcessConfig (Last Handle) -- | Lens for stdIn. stdInL :: Lens' ProcessConfig (Last Handle) -- | Lens for stdOut. stdOutL :: Lens' ProcessConfig (Last Handle) -- | The environment variables can be declared to inherit from the running -- process or they can be specifically added. data EnvironmentVariables EnvironmentVariables :: Last Bool -> Map String String -> EnvironmentVariables [inherit] :: EnvironmentVariables -> Last Bool [specific] :: EnvironmentVariables -> Map String String -- | Lens for inherit inheritL :: Lens' EnvironmentVariables (Last Bool) -- | Lens for specific. specificL :: Lens' EnvironmentVariables (Map String String) -- | A type to help combine command line Args. data CommandLineArgs CommandLineArgs :: Map String (Maybe String) -> Map Int String -> CommandLineArgs -- | Args of the form -h foo, --host=foo and -- --switch. The key is mappended with value so the key -- should include the space or equals (as shown in the first two examples -- respectively). The Dual monoid is used so the last key wins. [keyBased] :: CommandLineArgs -> Map String (Maybe String) -- | Args that appear at the end of the key based Args. The Dual -- monoid is used so the last key wins. [indexBased] :: CommandLineArgs -> Map Int String -- | Lens for indexBased. indexBasedL :: Lens' CommandLineArgs (Map Int String) -- | Lens for keyBased. keyBasedL :: Lens' CommandLineArgs (Map String (Maybe String)) -- | Used to specify a Temporary folder that is automatically -- cleaned up or a Permanent folder which is not automatically -- cleaned up. data DirectoryType -- | A permanent file that should not be generated. Permanent :: FilePath -> DirectoryType -- | A temporary file that needs to generated. Temporary :: DirectoryType -- | SocketClass is used to specify how postgres should -- listen for connections The two main options are a IpSocket -- which takes a hostname or IP address. if not is given the default it -- "127.0.0.1". Alternatively one can specify UnixSocket for a -- UNIX domain socket. If a directory is specified the socket will live -- in that folder. Otherwise a temporary folder will get created for the -- socket. data SocketClass -- | The monoid for combining IP address configuration. IpSocket :: Last String -> SocketClass -- | The monoid for combining UNIX socket configuration. UnixSocket :: DirectoryType -> SocketClass -- | A way to log internal Events type Logger = Event -> IO () -- | Internal events for debugging data Event -- | The first event. This useful for debugging what is actual passed to -- the initdb, createdb and postgres. StartPlan :: String -> Event -- | The second event. Postgres is about to get called StartPostgres :: Event -- | The third event. Postgres started. We are now about to setup a -- reconnect loop (racing with a process checker) WaitForDB :: Event -- | The fourth event and (possibly all subsequent events). We are looping -- trying to successfully connect to the postgres process. TryToConnect :: Event -- | This module provides functions for creating a temporary -- postgres instance. By default it will create a temporary data -- directory and a temporary directory for a UNIX domain socket for -- postgres to listen on. -- -- Here is an example using the expection safe with function: -- --
--   with $ \db -> bracket
--      (connectPostgreSQL (toConnectionString db))
--      close $
--      \conn -> execute_ conn "CREATE TABLE foo (id int)"
--   
-- -- To extend or override the defaults use withConfig (or -- startConfig). -- -- tmp-postgres ultimately calls (optionally) initdb, -- postgres and (optionally) createdb. -- -- All of the command line, environment variables and configuration files -- that are generated by default for the respective executables can be -- extended. -- -- In general tmp-postgres is useful if you want a clean -- temporary postgres and do not want to worry about clashing -- with an existing postgres instance (or needing to ensure -- postgres is already running). -- -- Here are some different use cases for tmp-postgres and their -- respective configurations: -- -- -- -- WARNING!! Ubuntu's PostgreSQL installation does not put -- initdb on the PATH. We need to add it manually. The -- necessary binaries are in the -- /usr/lib/postgresql/VERSION/bin/ directory, and should be -- added to the PATH -- --
--   echo "export PATH=$PATH:/usr/lib/postgresql/VERSION/bin/" >> /home/ubuntu/.bashrc
--   
module Database.Postgres.Temp -- | Default expectation safe interface. Equivalent to -- --
--   with = withConfig defaultConfig
--   
with :: (DB -> IO a) -> IO (Either StartError a) -- | Exception safe database create with options. See startConfig -- for more details. Calls stop even in the face of exceptions. withConfig :: Config -> (DB -> IO a) -> IO (Either StartError a) -- | Exception safe version of restart. withRestart :: DB -> (DB -> IO a) -> IO (Either StartError a) -- | Use the current database as a template and make a copy. Give the copy -- a random name. -- -- Equivalent to: -- --
--   withNewDb = withNewDbConfig mempty
--   
-- -- See startNewDbConfig for more details. withNewDb :: DB -> (DB -> IO a) -> IO (Either StartError a) -- | Exception safe version of startNewDbConfig. Creates a temporary -- database using the current database as a template. -- -- See startNewDbConfig for more details. withNewDbConfig :: ProcessConfig -> DB -> (DB -> IO a) -> IO (Either StartError a) -- | Default start behavior. Equivalent to calling startConfig with -- the defaultConfig. start :: IO (Either StartError DB) -- | Create zero or more temporary resources and use them to make a -- Config. -- -- The passed in config is inspected and a generated config is created. -- The final config is built by -- --
--   generated <> extra
--   
-- -- Based on the value of socketClass a "postgresql.conf" is -- created with: -- --
--   listen_addresses = 'IP_ADDRESS'
--   
-- -- if it is IpSocket. If is UnixSocket then the lines: -- --
--   listen_addresses = ''
--   unix_socket_directories = 'SOCKET_DIRECTORY'
--   
-- -- are added. -- -- Additionally the generated Config also does the -- following: -- -- -- -- All of these values can be overrided by the extra config. -- -- The returned DB requires cleanup. startConfig should be -- used with a bracket and stop, e.g. -- --
--   withConfig :: Config -> (DB -> IO a) -> IO (Either StartError a)
--   withConfig plan f = bracket (startConfig plan) (either mempty stop) $
--      either (pure . Left) (fmap Right . f)
--   
-- -- or just use withConfig. If you are calling startConfig -- you probably want withConfig anyway. startConfig :: Config -> IO (Either StartError DB) -- | Stop the postgres process and cleanup any temporary resources -- that might have been created. stop :: DB -> IO () -- | Restart the postgres from DB using the prior -- Plan. restart :: DB -> IO (Either StartError DB) -- | Only stop the postgres process but leave any temporary -- resources. Useful for testing backup strategies when used in -- conjunction with restart or withRestart. stopPostgres :: DB -> IO ExitCode -- | Use the current database as a template and make a copy. Give the copy -- a random name. -- -- Equivalent to: -- --
--   startNewDb = startNewDbConfig mempty
--   
-- -- See startNewDbConfig for more details. startNewDb :: DB -> IO (Either StartError DB) -- | Use the current database as a template and make a copy. Give the copy -- a random name. -- -- Copying a database from a template can be faster than creating a new -- postgres and migrating a database from scratch. In artifical -- benchmarks it appears to be about 2x faster. -- -- To use the current database as a template all connections to the -- database must be terminated first. -- -- To override the arguments passed to createdb one can pass in -- extra ProcessConfig. The combined process is -- created by mappended the generated with the -- extra ProcessConfig, e.g. -- --
--   combined = generated <> extra
--   
-- -- The current implementation has a few known issues. -- -- If a connection is made between the termination command and the -- createdb call the createdb call will fail. -- -- Additionally the generated name is 32 character random name of -- characters "a" to "z". It is possible, although unlikeily that a -- duplicate database name could be generated and this would also cause a -- failure. -- -- startNewDbConfig requires cleanup so it best to use a -- bracket along with stopNewDb. This is equivalient to -- withNewDbConfig. -- -- The only reason to use startNewDbConfig over -- withNewDbConfig is if you are unable to use -- withNewDbConfig for some reason. startNewDbConfig :: ProcessConfig -> DB -> IO (Either StartError DB) -- | Cleanup the temporary database created by startNewDbConfig or -- startNewDb. stopNewDb :: DB -> IO () -- | Handle for holding temporary resources, the postgres process -- handle and postgres connection information. The DB also -- includes the final plan used to start initdb, -- createdb and postgres. See toConnectionString -- or toConnectionOptions for converting a DB to postgresql -- connection string. data DB -- | Convert a DB to a connection string. Alternatively one can -- access the Options using toConnectionOptions. toConnectionString :: DB -> ByteString -- | Convert a DB to a connection Options type. toConnectionOptions :: DB -> Options -- | Access the data directory. This was either generated or specified -- explicitly when creating the Config toDataDirectory :: DB -> FilePath -- | Get the directory that is used to create other temporary directories toTemporaryDirectory :: DB -> FilePath -- | Make the data directory permanent. Useful for debugging. If you are -- using with or withConfig this function will not modify -- the DB that is passed for cleanup. You will need to setup your -- own bracket like -- --
--   bracket (fmap makeDataDirPermanent start) (either mempty stop)
--   
makeDataDirPermanent :: DB -> DB -- | Reload the configuration file without shutting down. Calls -- pg_reload_conf(). reloadConfig :: DB -> IO () -- | Display a DB. prettyPrintDB :: DB -> String -- | A list of failures that can occur when starting. This is not and -- exhaustive list but covers the errors that the system catches for the -- user. data StartError -- | postgres failed before a connection succeeded. Most likely -- this is due to invalid configuration StartPostgresFailed :: ExitCode -> StartError -- | initdb failed. This can be from invalid configuration or -- using a non-empty data directory InitDbFailed :: String -> String -> ExitCode -> StartError [startErrorStdOut] :: StartError -> String [startErrorStdErr] :: StartError -> String [startErrorExitCode] :: StartError -> ExitCode -- | createdb failed. This can be from invalid configuration or -- the database might already exist. CreateDbFailed :: String -> String -> ExitCode -> StartError [startErrorStdOut] :: StartError -> String [startErrorStdErr] :: StartError -> String [startErrorExitCode] :: StartError -> ExitCode -- | The Plan was missing info and a complete CompletePlan -- could not be created. CompletePlanFailed :: String -> [String] -> StartError -- | The ProcessConfig was missing info and a -- CompleteProcessConfig could not be created. CompleteProcessConfigFailed :: String -> [String] -> StartError -- | Timed out waiting for postgres to accept a connection ConnectionTimedOut :: StartError DeleteDbError :: SqlError -> StartError -- | The default configuration. This will create a database called -- "postgres" via initdb (it's default behavior). It will create -- a temporary directory for the data and a temporary directory for a -- unix socket on a random port. Additionally it will use the following -- "postgresql.conf" which is optimized for performance. -- --
--   shared_buffers = 12MB
--   fsync = off
--   synchronous_commit = off
--   full_page_writes = off
--   log_min_duration_statement = 0
--   log_connections = on
--   log_disconnections = on
--   client_min_messages = ERROR
--   
-- -- defaultConfig also passes the --no-sync flag to -- initdb. -- -- If you would like to customize this behavior you can start with the -- defaultConfig and overwrite fields or combine a -- defaultConfig with another Config using <> -- (mappend). -- -- Alternatively you can eschew defaultConfig altogether, however -- your postgres might start and run faster if you use -- defaultConfig. -- -- The defaultConfig also disables the logging of internal -- Events. -- -- To append additional lines to "postgresql.conf" file create a custom -- Config like the following. -- --
--   custom = defaultConfig <> mempty
--     { plan = mempty
--       { postgresConfigFile =
--           [ "wal_level = replica"
--           , "archive_mode = on"
--           , "max_wal_senders = 2"
--           , "fsync = on"
--           , "synchronous_commit = on"
--           ]
--       }
--     }
--   
-- -- Or using the provided lenses and your favorite lens library: -- --
--   custom = defaultConfig & planL . postgresConfigFile <>~
--     [ "wal_level = replica"
--     , "archive_mode = on"
--     , "max_wal_senders = 2"
--     , "fsync = on"
--     , "synchronous_commit = on"
--     ]
--   
-- -- This is common enough there is defaultPostgresConf which is a -- helper to do this. -- -- As an alternative to using defaultConfig one could create a -- config from connections parameters using -- optionsToDefaultConfig. defaultConfig :: Config -- | mappend the defaultConfig with a Config that -- provides additional "postgresql.conf" lines. Equivalent to: -- --
--   defaultPostgresConf extra = defaultConfig <> mempty
--     { plan = mempty
--       { postgresConfigFile = extra
--       }
--     }
--   
-- -- or with lenses: -- --
--   defaultPostgresConf extra = defaultConfig & planL . postgresConfigFile <>~ extra
--   
defaultPostgresConf :: [String] -> Config -- | The standardProcessConfig sets the handles to stdin, -- stdout and stderr and inherits the environment variables -- from the calling process. standardProcessConfig :: ProcessConfig -- | The same as defaultConfig but all the handles are set to -- devnull. See silentProcessConfig as well. silentConfig :: Config -- | silentProcessConfig sets the handles to devnull -- and inherits the environment variables from the calling process. silentProcessConfig :: ProcessConfig -- | Attempt to create a Config from a Options. Useful if you -- want to create a database owned by a specific user you will also login -- with among other use cases. optionsToDefaultConfig :: Options -> Config