Safe Haskell | None |
---|
This helper module is intended for use by the backend creators
- createMigration :: PersistBackend m => Migration m -> m NamedMigrations
- executeMigration :: (PersistBackend m, MonadIO m) => (String -> IO ()) -> NamedMigrations -> m ()
- executeMigrationUnsafe :: (PersistBackend m, MonadIO m) => (String -> IO ()) -> NamedMigrations -> m ()
- runMigration :: (PersistBackend m, MonadIO m) => (String -> IO ()) -> Migration m -> m ()
- runMigrationUnsafe :: (PersistBackend m, MonadIO m) => (String -> IO ()) -> Migration m -> m ()
- printMigration :: MonadIO m => NamedMigrations -> m ()
- mergeMigrations :: [SingleMigration] -> SingleMigration
- silentMigrationLogger :: String -> IO ()
- defaultMigrationLogger :: String -> IO ()
- failMessage :: PersistField a => a -> [PersistValue] -> String
- class (MonadIO m, MonadBaseControl IO m, MonadReader cm m, ConnectionManager cm conn) => HasConn m cm conn
- runDb :: HasConn m cm conn => DbPersist conn IO a -> m a
- withSavepoint :: (HasConn m cm conn, SingleConnectionManager cm conn, Savepoint conn) => String -> m a -> m a
- primToPersistValue :: (PersistBackend m, PrimitivePersistField a) => a -> m ([PersistValue] -> [PersistValue])
- primFromPersistValue :: (PersistBackend m, PrimitivePersistField a) => [PersistValue] -> m (a, [PersistValue])
- primToPurePersistValues :: (DbDescriptor db, PrimitivePersistField a) => Proxy db -> a -> [PersistValue] -> [PersistValue]
- primFromPurePersistValues :: (DbDescriptor db, PrimitivePersistField a) => Proxy db -> [PersistValue] -> (a, [PersistValue])
- primToSinglePersistValue :: (PersistBackend m, PrimitivePersistField a) => a -> m PersistValue
- primFromSinglePersistValue :: (PersistBackend m, PrimitivePersistField a) => PersistValue -> m a
- pureToPersistValue :: (PersistBackend m, PurePersistField a) => a -> m ([PersistValue] -> [PersistValue])
- pureFromPersistValue :: (PersistBackend m, PurePersistField a) => [PersistValue] -> m (a, [PersistValue])
- singleToPersistValue :: (PersistBackend m, SinglePersistField a) => a -> m ([PersistValue] -> [PersistValue])
- singleFromPersistValue :: (PersistBackend m, SinglePersistField a) => [PersistValue] -> m (a, [PersistValue])
- toSinglePersistValueUnique :: forall m v u. (PersistBackend m, PersistEntity v, IsUniqueKey (Key v (Unique u)), PrimitivePersistField (Key v (Unique u))) => u (UniqueMarker v) -> v -> m PersistValue
- fromSinglePersistValueUnique :: forall m v u. (PersistBackend m, PersistEntity v, IsUniqueKey (Key v (Unique u)), PrimitivePersistField (Key v (Unique u))) => u (UniqueMarker v) -> PersistValue -> m v
- toPersistValuesUnique :: forall m v u. (PersistBackend m, PersistEntity v, IsUniqueKey (Key v (Unique u))) => u (UniqueMarker v) -> v -> m ([PersistValue] -> [PersistValue])
- fromPersistValuesUnique :: forall m v u. (PersistBackend m, PersistEntity v, IsUniqueKey (Key v (Unique u))) => u (UniqueMarker v) -> [PersistValue] -> m (v, [PersistValue])
- toSinglePersistValueAutoKey :: forall m v. (PersistBackend m, PersistEntity v, PrimitivePersistField (AutoKey v)) => v -> m PersistValue
- fromSinglePersistValueAutoKey :: forall m v. (PersistBackend m, PersistEntity v, PrimitivePersistField (Key v BackendSpecific)) => PersistValue -> m v
- bracket :: MonadBaseControl IO m => m a -> (a -> m b) -> (a -> m c) -> m c
- finally :: MonadBaseControl IO m => m a -> m b -> m a
- onException :: MonadBaseControl IO m => m a -> m b -> m a
- data PSEmbeddedFieldDef = PSEmbeddedFieldDef {}
- applyEmbeddedDbTypeSettings :: [PSEmbeddedFieldDef] -> DbType -> DbType
- applyReferencesSettings :: Maybe ReferenceActionType -> Maybe ReferenceActionType -> DbType -> DbType
- findOne :: (Eq c, Show c) => String -> (a -> c) -> (b -> c) -> a -> [b] -> b
- replaceOne :: (Eq c, Show c) => String -> (a -> c) -> (b -> c) -> (a -> b -> b) -> a -> [b] -> [b]
- matchElements :: Show a => (a -> b -> Bool) -> [a] -> [b] -> ([a], [b], [(a, b)])
- haveSameElems :: Show a => (a -> b -> Bool) -> [a] -> [b] -> Bool
- mapAllRows :: Monad m => ([PersistValue] -> m a) -> RowPopper m -> m [a]
- phantomDb :: PersistBackend m => m (Proxy (PhantomDb m))
- isSimple :: [ConstructorDef] -> Bool
Migration
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
mergeMigrations :: [SingleMigration] -> SingleMigrationSource
Joins the migrations. The result is either all error messages or all queries
silentMigrationLogger :: String -> IO ()Source
No-op
defaultMigrationLogger :: String -> IO ()Source
Prints the queries to stdout
failMessage :: PersistField a => a -> [PersistValue] -> StringSource
Helpers for running Groundhog within custom monads
class (MonadIO m, MonadBaseControl IO m, MonadReader cm m, ConnectionManager cm conn) => HasConn m cm conn Source
This class helps to shorten the type signatures of user monadic code.
(MonadIO m, MonadBaseControl IO m, MonadReader cm m, ConnectionManager cm conn) => HasConn m cm conn |
runDb :: HasConn m cm conn => DbPersist conn IO a -> m aSource
It helps to run database operations within your application monad.
withSavepoint :: (HasConn m cm conn, SingleConnectionManager cm conn, Savepoint conn) => String -> m a -> m aSource
It helps to run withConnSavepoint
within a monad.
Helper functions for defining *PersistValue instances
primToPersistValue :: (PersistBackend m, PrimitivePersistField a) => a -> m ([PersistValue] -> [PersistValue])Source
primFromPersistValue :: (PersistBackend m, PrimitivePersistField a) => [PersistValue] -> m (a, [PersistValue])Source
primToPurePersistValues :: (DbDescriptor db, PrimitivePersistField a) => Proxy db -> a -> [PersistValue] -> [PersistValue]Source
primFromPurePersistValues :: (DbDescriptor db, PrimitivePersistField a) => Proxy db -> [PersistValue] -> (a, [PersistValue])Source
primToSinglePersistValue :: (PersistBackend m, PrimitivePersistField a) => a -> m PersistValueSource
primFromSinglePersistValue :: (PersistBackend m, PrimitivePersistField a) => PersistValue -> m aSource
pureToPersistValue :: (PersistBackend m, PurePersistField a) => a -> m ([PersistValue] -> [PersistValue])Source
pureFromPersistValue :: (PersistBackend m, PurePersistField a) => [PersistValue] -> m (a, [PersistValue])Source
singleToPersistValue :: (PersistBackend m, SinglePersistField a) => a -> m ([PersistValue] -> [PersistValue])Source
singleFromPersistValue :: (PersistBackend m, SinglePersistField a) => [PersistValue] -> m (a, [PersistValue])Source
toSinglePersistValueUnique :: forall m v u. (PersistBackend m, PersistEntity v, IsUniqueKey (Key v (Unique u)), PrimitivePersistField (Key v (Unique u))) => u (UniqueMarker v) -> v -> m PersistValueSource
fromSinglePersistValueUnique :: forall m v u. (PersistBackend m, PersistEntity v, IsUniqueKey (Key v (Unique u)), PrimitivePersistField (Key v (Unique u))) => u (UniqueMarker v) -> PersistValue -> m vSource
toPersistValuesUnique :: forall m v u. (PersistBackend m, PersistEntity v, IsUniqueKey (Key v (Unique u))) => u (UniqueMarker v) -> v -> m ([PersistValue] -> [PersistValue])Source
fromPersistValuesUnique :: forall m v u. (PersistBackend m, PersistEntity v, IsUniqueKey (Key v (Unique u))) => u (UniqueMarker v) -> [PersistValue] -> m (v, [PersistValue])Source
toSinglePersistValueAutoKey :: forall m v. (PersistBackend m, PersistEntity v, PrimitivePersistField (AutoKey v)) => v -> m PersistValueSource
fromSinglePersistValueAutoKey :: forall m v. (PersistBackend m, PersistEntity v, PrimitivePersistField (Key v BackendSpecific)) => PersistValue -> m vSource
Other
:: 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 |
:: 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 aSource
applyReferencesSettings :: Maybe ReferenceActionType -> Maybe ReferenceActionType -> DbType -> DbTypeSource
replaceOne :: (Eq c, Show c) => String -> (a -> c) -> (b -> c) -> (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] -> BoolSource
mapAllRows :: Monad m => ([PersistValue] -> m a) -> RowPopper m -> m [a]Source
phantomDb :: PersistBackend m => m (Proxy (PhantomDb m))Source
isSimple :: [ConstructorDef] -> BoolSource