eventium-postgresql: Postgres implementations for eventium

[ database, eventsourcing, library, mit, postgresql ] [ Propose Tags ] [ Report a vulnerability ]

Eventium-postgresql provides a PostgreSQL-based event store implementation for the Eventium event sourcing framework. It uses the Persistent library for type-safe database access and provides efficient event storage and retrieval with support for aggregate streams, event versioning, and optimistic concurrency control. This is a production-ready backend for event-sourced applications.


[Skip to Readme]

Modules

[Last Documentation]

  • Eventium
    • ProjectionCache
      • Eventium.ProjectionCache.Postgresql
    • Store
      • Eventium.Store.Postgresql

Flags

Manual Flags

NameDescriptionDefault
ci

Enable -Werror for CI builds

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0, 0.2.1
Change log CHANGELOG.md
Dependencies aeson (>=1.5 && <2.3), base (>=4.9 && <5), bytestring (>=0.10 && <0.13), eventium-core (>=0.2.0 && <0.3.0), eventium-sql-common (>=0.2.0 && <0.3.0), mtl (>=2.2 && <2.4), persistent (>=2.14 && <2.18), text (>=1.2 && <2.2) [details]
License MIT
Author
Maintainer Alexander Sidorenko
Uploaded by aleks_sidorenko at 2026-03-06T14:29:16Z
Category Database, Eventsourcing, PostgreSQL
Home page https://github.com/aleks-sidorenko/eventium#readme
Bug tracker https://github.com/aleks-sidorenko/eventium/issues
Source repo head: git clone https://github.com/aleks-sidorenko/eventium
Distributions
Downloads 8 total (4 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2026-03-06 [all 2 reports]

Readme for eventium-postgresql-0.2.1

[back to package description]

Eventium PostgreSQL

PostgreSQL event store backend for Eventium.

Overview

eventium-postgresql provides a production-grade event store backed by PostgreSQL. It uses the persistent library for type-safe database access and guarantees monotonically increasing global sequence numbers via LOCK IN EXCLUSIVE MODE.

API

postgresqlEventStoreWriter
  :: (MonadIO m)
  => SqlEventStoreConfig entity serialized
  -> VersionedEventStoreWriter (SqlPersistT m) serialized

Readers come from eventium-sql-common (re-exported):

sqlEventStoreReader       :: SqlEventStoreConfig entity serialized -> VersionedEventStoreReader (SqlPersistT m) serialized
sqlGlobalEventStoreReader :: SqlEventStoreConfig entity serialized -> GlobalEventStoreReader (SqlPersistT m) serialized

Usage

import Eventium.Store.Postgresql
import Database.Persist.Postgresql

main :: IO ()
main = runStdoutLoggingT $
  withPostgresqlPool connStr 10 $ \pool -> do
    -- Use defaultSqlEventStoreConfig for the standard schema
    let writer = postgresqlEventStoreWriter defaultSqlEventStoreConfig
        reader = sqlEventStoreReader defaultSqlEventStoreConfig
    flip runSqlPool pool $ do
      runMigration migrateSqlEvent
      -- writer and reader are ready to use

Setup

# Start PostgreSQL with docker-compose (from project root)
docker compose up -d

# Default connection settings (matching docker-compose.yaml):
# POSTGRES_HOST=127.0.0.1  POSTGRES_PORT=5432
# POSTGRES_USER=postgres   POSTGRES_PASSWORD=password
# POSTGRES_DBNAME=eventium_test

Concurrency

PostgreSQL uses LOCK table_name IN EXCLUSIVE MODE during writes. This ensures that auto-increment IDs are assigned in commit order, so concurrent readers always see a gapless, monotonically increasing global sequence.

Installation

dependencies:
  - eventium-core
  - eventium-postgresql
  - persistent-postgresql

Documentation

License

MIT -- see LICENSE.md