groundhog-0.0.1: Type-safe, relational, multi-backend persistence.

Database.Groundhog.Generic

Description

This helper module is intended for use by the backend creators

Synopsis

Documentation

migrateRecursivelySource

Arguments

:: (Monad m, PersistEntity e) 
=> (EntityDef -> m SingleMigration)

migrate entity

-> (Int -> [NamedType] -> m SingleMigration)

migrate tuple

-> (NamedType -> m SingleMigration)

migrate list

-> e

initial entity

-> StateT NamedMigrations m () 

Create migration for a given entity and all entities it depends on. The stateful Map is used to avoid duplicate migrations when an entity type occurs several times in a datatype

createMigration :: PersistBackend m => Migration m -> m NamedMigrationsSource

Produce the migrations but not execute them. Fails when an unsafe migration occurs.

executeMigration :: (PersistBackend m, MonadIO m) => (String -> IO ()) -> NamedMigrations -> m ()Source

Execute the migrations and log them.

executeMigrationUnsafe :: (PersistBackend m, MonadIO m) => (String -> IO ()) -> NamedMigrations -> m ()Source

Execute migrations and log them. Executes the unsafe migrations without warnings

runMigration :: (PersistBackend m, MonadIO m) => (String -> IO ()) -> Migration m -> m ()Source

Run migrations and log them. Fails when an unsafe migration occurs.

runMigrationUnsafe :: (PersistBackend m, MonadIO m) => (String -> IO ()) -> Migration m -> m ()Source

Run migrations and log them. Executes the unsafe migrations without warnings

printMigration :: MonadIO m => NamedMigrations -> m ()Source

Pretty print the migrations

getEntityName :: EntityDef -> StringSource

Get full entity name with the names of its parameters.

 getEntityName (entityDef v) == persistName v

mergeMigrations :: [SingleMigration] -> SingleMigrationSource

Joins the migrations. The result is either all error messages or all queries

defaultMigrationLogger :: String -> IO ()Source

Prints the queries to stdout

defaultSelect :: (PersistBackend m, PersistEntity v, Constructor c) => Cond v c -> [Order v c] -> Int -> Int -> m [(Key v, v)]Source

Call selectEnum but return the result as a list

defaultSelectAll :: (PersistBackend m, PersistEntity v) => m [(Key v, v)]Source

Call selectAllEnum but return the result as a list