-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Create a temporary database that is deleted after performing some operation -- -- Please see README.md @package postgres-tmp @version 0.2.0 -- | Create temporary postgresql databases. -- -- The main usecase for this are tests where you don’t want to assume -- that a certain database exists. module Database.PostgreSQL.Tmp -- | Connection string for the postgres database owned by the -- postgres user defaultDB :: ByteString -- | The data necessary to connect to the temporary database data DBInfo DBInfo :: Text -> Text -> DBInfo [dbName] :: DBInfo -> Text [roleName] :: DBInfo -> Text -- | Convenience wrapper for withTmpDB' using defaultDB withTmpDB :: (DBInfo -> IO a) -> IO a -- | Create a temporary database and a temporary role that the callback can -- operate on. After the action has finished the database and the role -- are destroyed. -- -- This is a bracket-style wrapper around createTmpDB and -- dropTmpDB -- -- This function assumes that the connection string points to a database -- containing the tables called pg_roles and -- pg_database and that the user has the CREATEDB and -- CREATEROLE privileges. withTmpDB' :: ByteString -> (DBInfo -> IO a) -> IO a -- | Create a temporary database and a temporary role. -- -- To destroy the database and the role use dropTmpDB. -- -- This function assumes that the connection string points to a database -- containing the tables called pg_roles and -- pg_database and that the user has the CREATEDB and -- CREATEROLE privileges. createTmpDB :: ByteString -> IO (Connection, DBInfo) -- | Destroy the database and the role created by createTmpDB. dropTmpDB :: (Connection, DBInfo) -> IO () -- | Create a new role that does not already exist and return its name. -- -- The new role does not have a password and has the CREATEDB -- privilege. The database that the connection points to is assumed to -- contain a table called pg_roles with a rolname -- column. newRole :: Connection -> IO Text -- | Drop the role. dropRole :: Connection -> Text -> IO Int64 -- | Create a new database that is owned by the user. newDB :: Connection -> Text -> IO Text -- | Drop the database. dropDB :: Connection -> Text -> IO Int64 instance GHC.Classes.Ord Database.PostgreSQL.Tmp.DBInfo instance GHC.Classes.Eq Database.PostgreSQL.Tmp.DBInfo instance GHC.Read.Read Database.PostgreSQL.Tmp.DBInfo instance GHC.Show.Show Database.PostgreSQL.Tmp.DBInfo