Converts the parameters parsed from a database url to the concrete configuration types required by persistent.
Currently, only persistent-postgresql's PostgresConf
is provided.
cabal install persistent-database-url
Adjusting the Yesod scaffold to run on Heroku:
config/settings.yml
database-url: "_env:DATABASE_URL:postgres://user:pass@localhost:5432/dbname"
database-pool-size: "_env:DB_POOL:5"
Settings.hs:
import Database.Persist.URL (fromDatabaseUrl)
instance FromJSON AppSettings where
parseJSON = withObject "AppSettings" $ \o -> do
appDatabaseConf <- fromDatabaseUrl
<$> o .: "database-pool-size"
<*> o .: "database-url"
-- ...
return AppSettings {..}
stack test