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.

Related Blog Posts
Natively Compiled Java on Google App Engine
Google App Engine is a platform-as-a-service product that is marketed as a way to get your applications into the cloud without necessarily knowing all of the infrastructure bits and pieces to do so. Google App […]
Building Better Data Visualization Experiences: Part 2 of 2
If you don't have a Ph.D. in data science, the raw data might be difficult to comprehend. This is where data visualization comes in.
Unleashing Feature Flags onto Kafka Consumers
Feature flags are a tool to strategically enable or disable functionality at runtime. They are often used to drive different user experiences but can also be useful in real-time data systems. In this post, we’ll […]
A security model for developers
Software security is more important than ever, but developing secure applications is more confusing than ever. TLS, mTLS, RBAC, SAML, OAUTH, OWASP, GDPR, SASL, RSA, JWT, cookie, attack vector, DDoS, firewall, VPN, security groups, exploit, […]