eventium-postgresql: Postgres implementations for eventium

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Warnings:

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]

Properties

Versions 0.1.0, 0.2.1, 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
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
Uploaded by aleks_sidorenko at 2026-03-06T13:53:53Z

Modules

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


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