This helper module is intended for use by the backend creators
- migrateRecursively :: (Monad m, PersistEntity e) => (EntityDef -> m SingleMigration) -> (Int -> [NamedType] -> m SingleMigration) -> (NamedType -> m SingleMigration) -> e -> StateT NamedMigrations m ()
- 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 ()
- getEntityName :: EntityDef -> String
- mergeMigrations :: [SingleMigration] -> SingleMigration
- silentMigrationLogger :: String -> IO ()
- defaultMigrationLogger :: String -> IO ()
- defaultSelect :: (PersistBackend m, PersistEntity v, Constructor c) => Cond v c -> [Order v c] -> Int -> Int -> m [(Key v, v)]
- defaultSelectAll :: (PersistBackend m, PersistEntity v) => m [(Key v, v)]
Documentation
:: (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
silentMigrationLogger :: String -> IO ()Source
No-op
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