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
- primToPersistValue :: (PersistBackend m, PrimitivePersistField a) => a -> m ([PersistValue] -> [PersistValue])
- primFromPersistValue :: (PersistBackend m, PrimitivePersistField a) => [PersistValue] -> m (a, [PersistValue])
- 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
- 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
Helper functions defining *PersistValue instances
primToPersistValue :: (PersistBackend m, PrimitivePersistField a) => a -> m ([PersistValue] -> [PersistValue])Source
primFromPersistValue :: (PersistBackend m, PrimitivePersistField a) => [PersistValue] -> m (a, [PersistValue])Source
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
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