groundhog-0.12.0: Type-safe datatype-database mapping library.
Safe HaskellNone
LanguageHaskell2010

Database.Groundhog.Generic

Description

This helper module is intended for use by the backend creators

Synopsis

Migration

createMigration :: Monad m => Migration m -> m NamedMigrations Source #

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

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

Execute the migrations with printing to stderr. Fails when an unsafe migration occurs.

executeMigrationSilent :: (PersistBackend m, MonadIO m) => NamedMigrations -> m () Source #

Execute the migrations. Fails when an unsafe migration occurs.

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

Execute migrations. Executes the unsafe migrations without warnings and prints them to stderr

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

Creates migrations and executes them with printing to stderr. Fails when an unsafe migration occurs. > runMigration m = createMigration m >>= executeMigration

runMigrationSilent :: (PersistBackend m, MonadIO m) => Migration m -> m () Source #

Creates migrations and silently executes them. Fails when an unsafe migration occurs. > runMigration m = createMigration m >>= executeMigrationSilent

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

Creates migrations and executes them with printing to stderr. Executes the unsafe migrations without warnings > runMigrationUnsafe m = createMigration m >>= executeMigrationUnsafe

getQueries Source #

Arguments

:: Bool

True - support unsafe queries

-> SingleMigration 
-> Either [String] [String] 

Returns either a list of errors in migration or a list of queries

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

Pretty print the migrations

mergeMigrations :: [SingleMigration] -> SingleMigration Source #

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

Helper functions for defining *PersistValue instances

Other

bracket Source #

Arguments

:: MonadBaseControl IO m 
=> m a

computation to run first ("acquire resource")

-> (a -> m b)

computation to run last ("release resource")

-> (a -> m c)

computation to run in-between

-> m c 

finally Source #

Arguments

:: MonadBaseControl IO m 
=> m a

computation to run first

-> m b

computation to run afterward (even if an exception was raised)

-> m a 

onException :: MonadBaseControl IO m => m a -> m b -> m a Source #

data PSFieldDef str Source #

Constructors

PSFieldDef 

Fields

Instances

Instances details
Eq str => Eq (PSFieldDef str) Source # 
Instance details

Defined in Database.Groundhog.Generic

Methods

(==) :: PSFieldDef str -> PSFieldDef str -> Bool #

(/=) :: PSFieldDef str -> PSFieldDef str -> Bool #

Show str => Show (PSFieldDef str) Source # 
Instance details

Defined in Database.Groundhog.Generic

Methods

showsPrec :: Int -> PSFieldDef str -> ShowS #

show :: PSFieldDef str -> String #

showList :: [PSFieldDef str] -> ShowS #

findOne :: (Eq x, Show x) => String -> (a -> x) -> x -> [a] -> a Source #

replaceOne :: (Eq x, Show x) => String -> (a -> x) -> (b -> x) -> (a -> b -> b) -> a -> [b] -> [b] Source #

matchElements :: Show a => (a -> b -> Bool) -> [a] -> [b] -> ([a], [b], [(a, b)]) Source #

Returns only old elements, only new elements, and matched pairs (old, new). The new ones exist only in datatype, the old are present only in DB, match is typically by name (the properties of the matched elements may differ).

haveSameElems :: Show a => (a -> b -> Bool) -> [a] -> [b] -> Bool Source #

phantomDb :: PersistBackend m => m (proxy (Conn m)) Source #

getUniqueFields :: UniqueDef' str (Either field str) -> [field] Source #

firstRow :: MonadIO m => RowStream a -> m (Maybe a) Source #

mapStream :: PersistBackendConn conn => (a -> Action conn b) -> RowStream a -> Action conn (RowStream b) Source #

joinStreams :: [Action conn (RowStream a)] -> Action conn (RowStream a) Source #