Run Grails Commands on Heroku

Instructions on how to run Grails commands on Heroku using an example of how to run Grails migrations on Heroku.

Brandon Fish

I recently needed to run Grails database migrations on Heroku and used the following steps to run these.

First,  the Grails wrapper is required which can be installed using the wrapper command.

After running the wrapper command for the first time on Heroku, it complained that JAVAHOME needs to be set. So, I used the following command to determine JAVAHOME:

$ heroku run which java
Running `which java` attached to terminal... up, run.6852
/app/.jdk/bin/java

I used just the home part of the path to set the JAVA_HOME variable:

$ heroku config:set JAVA_HOME='/app/.jdk'
Setting config vars and restarting ... done, v22
JAVA_HOME: /app/.jdk

Next, I ran the migration command with the environment I required:

$ heroku run ./grailsw -Dgrails.env=production dbm-update
| Finished dbm-update

Finally, I confirmed the tables were created that I needed:

$ heroku pg:info
=== HEROKU_POSTGRESQL_PURPLE_URL (DATABASE_URL)
Plan: Dev
Status: Available
Connections: 0
PG Version: 9.3.3
Created: 2014-05-11 03:38 UTC
Data Size: 6.6 MB
Tables: 3
Rows: 3/10000 (In compliance)

Using the above  steps, the Grails wrapper command could also be used to run other Grails commands on Heroku.

Share this Post

Related Blog Posts

JVM

Configuring Spring Security CAS Providers with Java Config

May 20th, 2014

It can take a little digging to move Spring Security + CAS XML configuration to Java. Here is the Java config equivalent to the SS documentations example.

Object Partners
JVM

Automatically test your dirty Grails classes

May 15th, 2014

A script to grab the list of modified files from git, parse their filenames, and pass those names for testing in grails test-app.

Igor Shults
JVM

Grails R14 Error (Memory quota exceeded) on Heroku

May 13th, 2014

Explains how to resolve the Grails R14 Error when it is encountered on Heroku.

Brandon Fish

About the author

Brandon Fish

Sr. Consultant

Brandon has over 6 years of software development experience with Spring and related JEE technologies including the last year plus working on a large scale enterprise Grails application. He has successfully delivered client projects using a variety of technologies and filling many project roles including lead software developer, requirements gatherer, domain expert, systems administrator, offshore team manager, and Scrum master. He is passionate and up to date with best software development practices in order to deliver projects efficiently, meeting client expectations and with a high quality.