@hackage haskell-bee-pgmq0.1.0.0
PostgreSQL/PGMQ broker implementation for haskell-bee
Categories
License
AGPL-3.0-or-later
Maintainer
gargantext@iscpif.fr
Links
- Homepage
- Documentation
- No source repository
- Security
Versions
- 0.1.0.0 Mon, 16 Jun 2025
Installation
Dependencies (16)
- aeson >=2.1 && <2.3
- base >=4.17.2.0 && <5
- bytestring >=0.11 && <0.13
- containers >=0.6.7 && <0.8
- deepseq >=1.0.0.0 && <1.7
- haskell-bee ^>=0.1.0.0 Show all…
Dependents (0)
haskell-bee-pgmq
PostgreSQL/PGMQ broker implementation for haskell-bee.
This package provides a PostgreSQL-backed message queue broker using PGMQ (PostgreSQL Message Queue).
Database initialization
Notice that upon broker initialization, this calls PGMQ.initialize
which tries very hard to create the pgmq schema for you.
If you also want to pre-create the database itself, with some given user, you can try something like this:
import Shelly qualified as SH
createDBIfNotExists :: Text -> Text -> IO ()
createDBIfNotExists connStr dbName = do
-- For the \gexec trick, see:
-- https://stackoverflow.com/questions/18389124/simulate-create-database-if-not-exists-for-postgresql
(_res, _ec) <- SH.shelly $ SH.silently $ SH.escaping False $ do
let sql = "\"SELECT 'CREATE DATABASE " <> dbName <> "' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = '" <> dbName <> "')\\gexec\""
result <- SH.run "echo" [sql, "|", "psql", "-d", "\"" <> connStr <> "\""]
(result,) <$> SH.lastExitCode
return ()