Configuring Greenfield for Postgres

This tutorial will walk you through the steps to configure Greenfield for Postgres. We will make a few small changes to a couple config files then will build a deployable war package.

This tutorial assumes you have already created an Ubuntu 14.04 x64 VPS instance and have installed and configured Apache, Tomcat & Postgres. If you haven't done this already, follow Minimum Server Setup : Apache, Tomcat & Greenfield on Ubuntu 14.04 and Installing & Configuring Postgres for detailed instructions on how to install and configure Apache, Tomcat & Postgres for Greenfield

This tutorial also assumes you have downloaded and installed Grails and have Greenfield's source ready for modification

1. Update BuildConfig.groovy

Uncomment following line so it reads

compile "postgresql:postgresql:9.1-901.jdbc4"

2. Update DataSource.groovy

Uncomment Postgres settings in the production dataSource section so it looks like

Substitute your postgres password for the password in this example

This example assumes that you have created a Postgres database named greenfield that is running locally on your web server.

production {
    dataSource {
		pooled = true
		dialect = org.hibernate.dialect.PostgreSQLDialect 
		dbCreate = "update" // one of 'create', 'create-drop','update'
		url = "jdbc:postgresql://localhost:5432/greenfield"
		driverClassName = "org.postgresql.Driver"
		username = "postgres"
		password = "postgres password"
		properties {
			maxActive = -1
			validationQuery="SELECT 1"

3. Build new greenfield.war

cd into top level greenfield directory and run

grails war

Now you have a war file that is ready to be deployed via Tomcat and run against a Postgres database running locally with a database named greenfield