eventsourcing-postgresql-0.9.0: PostgreSQL adaptor for eventsourcing.

Safe HaskellNone
LanguageHaskell2010

Database.CQRS.PostgreSQL.Migration

Synopsis

Documentation

migrate Source #

Arguments

:: (WritableEvent (EventType (StreamType transformedStreamFamily)), Stream m (StreamType transformedStreamFamily), StreamFamily m transformedStreamFamily, MonadError Error m, Hashable (StreamIdentifier transformedStreamFamily), MonadIO m, Ord (EventIdentifier (StreamType transformedStreamFamily)), Ord (StreamIdentifier transformedStreamFamily), FromField (StreamIdentifier transformedStreamFamily), FromField (EventIdentifier (StreamType transformedStreamFamily)), FromRow (EventMetadata (StreamType transformedStreamFamily)), FromField (EncodingFormat (EventType (StreamType transformedStreamFamily))), ToField (StreamIdentifier transformedStreamFamily), ToField (EventIdentifier (StreamType transformedStreamFamily)), ToRow (EventMetadata (StreamType transformedStreamFamily)), ToField (EncodingFormat (EventType (StreamType transformedStreamFamily))), Show (EventIdentifier (StreamType transformedStreamFamily))) 
=> StreamFamily streamId eventId metadata event 
-> (StreamFamily streamId eventId metadata event -> transformedStreamFamily) 
-> Query

Name of the new (temporary) relation.

-> Query

New stream identifier column name.

-> Query

New event identifier column name.

-> [Query]

New metadata column names.

-> Query

New event column name.

-> (Query -> Query)

Initialisation query that creates the new relation. It is given the name of the current relation to migrate. It must be idempotent to be able to restart the migrator.

-> (Query -> Query)

Query to lock the relation used by the application. It is given the name of the current relation. It must be idempotent to be able to restart the migrator.

-> (Query -> Query)

Query to swap the relation used by the application. It is given the name of the current relation.

-> m () 

Migrate a stream family stored in a PostgreSQL database to the same database. It is meant to run in parallel with the application using the stream family without disturbing it.

An alternative use of this is to migrate a stream family to a new relation without swapping the tables at the end. The old table stays in use by the application and the new one can be read by an external system for instance.

If the new table already exists (and the initialisation query does not fail in that case,) the migration will start over from the point it left off.