Skip to content

Instantly share code, notes, and snippets.

@camelpunch
Created September 29, 2014 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save camelpunch/ab2bcbd37aae04c941a4 to your computer and use it in GitHub Desktop.
Save camelpunch/ab2bcbd37aae04c941a4 to your computer and use it in GitHub Desktop.
Configuring Grails for postgres
dataSource {
pooled = true
jmxExport = true
driverClassName = "org.postgresql.Driver"
dialect = org.hibernate.dialect.PostgreSQLDialect
uri = new URI(System.env.DATABASE_URL)
username = uri.userInfo ? uri.userInfo.split(":")[0] : ""
password = uri.userInfo ? uri.userInfo.split(":")[1] : ""
url = "jdbc:postgresql://" + uri.host + uri.path
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
singleSession = true // configure OSIV singleSession mode
flush.mode = 'manual' // OSIV session flush mode outside of transactional context
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
}
}
test {
dataSource {
dbCreate = "update"
}
}
production {
dataSource {
dbCreate = "update"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment