May 22, 2014

Run Grails Commands on Heroku

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 JAVA_HOME needs to be set. So, I used the following command to determine JAVA_HOME:

$ 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.

About the Author

Object Partners profile.
Leave a Reply

Your email address will not be published. Required fields are marked *

Related Blog Posts
SwiftGen with Image & Color Asset Catalogs
You might remember back in 2015 when iOS 9 was introduced, and we were finally given a way to manage all of our assets in one place with Asset Catalogs. A few years later, support […]
Managing your Helm deployments with Helmfile
As we’ve been using Kubernetes to build software delivery platforms for our clients, we’ve found Helm to be a reasonable solution to templating and managing deployments to Kubernetes.  Although templating alternatives such as Kustomize have […]
AWS CodeBuild Test Reports for Gradle builds
Although AWS documentation has instructions for adding Test Reports for a maven build they currently lack instructions for a gradle build. You can find the maven instructions here: https://aws.amazon.com/blogs/devops/test-reports-with-aws-codebuild/ Assuming you have your gradle wrapper […]
Structuring SwiftUI Previews for API Calls
SwiftUI, together with Combine and Xcode 11+, provide a powerful toolset for quickly creating an app with a native UI. In Xcode 11+, the preview pane was introduced in order to provide live snapshots of […]