Safe Haskell | None |
---|---|
Language | Haskell2010 |
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.
- data MigrationStore = MigrationStore {
- loadMigration :: String -> IO (Either String Migration)
- saveMigration :: Migration -> IO ()
- getMigrations :: IO [String]
- fullMigrationName :: String -> IO String
- data MapValidationError
- data StoreData = StoreData {}
- type MigrationMap = Map String Migration
- loadMigrations :: MigrationStore -> IO (Either [MapValidationError] StoreData)
- storeMigrations :: StoreData -> [Migration]
- storeLookup :: StoreData -> String -> Maybe Migration
- depGraphFromMapping :: MigrationMap -> Either String (DependencyGraph Migration)
- validateMigrationMap :: MigrationMap -> [MapValidationError]
- validateSingleMigration :: MigrationMap -> Migration -> [MapValidationError]
- leafMigrations :: StoreData -> [String]
Documentation
data MigrationStore Source
The type of migration storage facilities. A MigrationStore is a facility in which new migrations can be created, and from which existing migrations can be loaded.
MigrationStore | |
|
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. |
InvalidMigration String | The specified migration is invalid. |
type MigrationMap = Map String Migration Source
High-level Store API
loadMigrations :: MigrationStore -> IO (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.
validateMigrationMap :: MigrationMap -> [MapValidationError] Source
Validate a migration map. Returns zero or more validation errors.
validateSingleMigration :: MigrationMap -> Migration -> [MapValidationError] Source
Validate a single migration. Looks up the migration's
dependencies in the specified MigrationMap
and returns a
MapValidationError
for each one that does not exist in the map.
leafMigrations :: StoreData -> [String] Source
Finds migrations that no other migration depends on (effectively finds all vertices with in-degree equal to zero).