Safe Haskell | None |
---|---|
Language | Haskell2010 |
Create temporary postgresql databases.
The main usecase for this are tests where you don’t want to assume that a certain database exists.
- defaultDB :: ByteString
- data DBInfo = DBInfo {}
- withTmpDB :: (DBInfo -> IO a) -> IO a
- withTmpDB' :: ByteString -> (DBInfo -> IO a) -> IO a
- createTmpDB :: ByteString -> IO (Connection, DBInfo)
- dropTmpDB :: (Connection, DBInfo) -> IO ()
- newRole :: Connection -> IO Text
- dropRole :: Connection -> Text -> IO Int64
- newDB :: Connection -> Text -> IO Text
- dropDB :: Connection -> Text -> IO Int64
Documentation
defaultDB :: ByteString Source #
Connection string for the postgres
database owned by the
postgres
user
The data necessary to connect to the temporary database
withTmpDB' :: ByteString -> (DBInfo -> IO a) -> IO a Source #
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.
Low level APIs
createTmpDB :: ByteString -> IO (Connection, DBInfo) Source #
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.
dropTmpDB :: (Connection, DBInfo) -> IO () Source #
Destroy the database and the role created by createTmpDB
.