Call something like the following in your initializer.
runMigration defaultMigrationLogger $ do
migrate (undefined :: BlogPost)
migrate (undefined :: BlogComment)
...
You can find more info on groundhog's migration functions here
http://hackage.haskell.org/package/groundhog-0.7.0/docs/Database-Groundhog.html#g:3
Technically none of the other DBs require a snaplet either. But in
practice, there is some boilerplate involved in using them because of
the way their APIs are designed. Groundhog's API (the
ConnectionManager type class in particular) requires less boilerplate
than persistent and postgresql-simple, so the amount of boilerplate is
small enough that having a snaplet for it doesn't really make sense.
The boilerplate ends up looking something like this:
data App = App
{ _heist :: Snaplet (Heist App)
, _sess :: Snaplet SessionManager
, _gh :: Pool Postgresql
...
}
instance ConnectionManager App Postgresql where
withConn f app = withConn f (_gh app)
withConnNoTransaction f app = withConnNoTransaction f (_gh app)
runGH :: ConnectionManager b conn
=> DbPersist conn (NoLoggingT IO) a
-> Handler b v a
runGH f = withTop' id $ do
cm <- ask
liftIO $ runNoLoggingT (withConn (runDbPersist f) cm)
In snap 1.0 this will be even less because the impedance mismatch
between MonadCatchIO-transformers and monad-control will be gone.
IIRC this will make the runGH function unnecessary.
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Snap Framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
snap_framewor...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.