This module provides an abstraction for a migration store, a
facility in which Migration
s can be stored and from which they
can be loaded. This module also provides functions for taking
Migration
s from a store and converting them into the appropriate
intermediate types for use with the rest of this library.
- class Monad m => MigrationStore s m where
- loadMigration :: s -> String -> m (Maybe Migration)
- saveMigration :: s -> Migration -> m ()
- getMigrations :: s -> m [String]
- fullMigrationName :: s -> String -> m String
- data MapValidationError
- data StoreData = StoreData {}
- type MigrationMap = Map String Migration
- loadMigrations :: MigrationStore s m => s -> m (Either [MapValidationError] StoreData)
- storeMigrations :: StoreData -> [Migration]
- storeLookup :: StoreData -> String -> Maybe Migration
- depGraphFromMapping :: MigrationMap -> Either String (DependencyGraph Migration)
Documentation
class Monad m => MigrationStore s m whereSource
A type class for types which represent a storage facility (and a monad context in which to operate on the store). A MigrationStore is a facility in which new migrations can be created, and from which existing migrations can be loaded.
loadMigration :: s -> String -> m (Maybe Migration)Source
Load a migration from the store.
saveMigration :: s -> Migration -> m ()Source
Save a migration to the store.
getMigrations :: s -> m [String]Source
Return a list of all available migrations' names.
fullMigrationName :: s -> String -> m StringSource
Return the full representation of a given migration name; mostly for filesystem stores, where the full representation includes the store path.
data MapValidationError Source
A type for types of validation errors for migration maps.
DependencyReferenceError String String | A migration claims a dependency on a migration that does not exist. |
DependencyGraphError String | An error was encountered when constructing the dependency graph for this store. |
type MigrationMap = Map String MigrationSource
High-level Store API
loadMigrations :: MigrationStore s m => s -> m (Either [MapValidationError] StoreData)Source
Load migrations from the specified MigrationStore
, validate the
loaded migrations, and return errors or a MigrationMap
on
success. Generally speaking, this will be the first thing you
should call once you have constructed a MigrationStore
.
storeMigrations :: StoreData -> [Migration]Source
Miscellaneous Functions
depGraphFromMapping :: MigrationMap -> Either String (DependencyGraph Migration)Source
Create a DependencyGraph
from a MigrationMap
; returns Left if
the dependency graph cannot be constructed (e.g., due to a
dependency cycle) or Right on success. Generally speaking, you
won't want to use this directly; use loadMigrations
instead.