Shyam Ramineni
Shyam Ramineni

Reputation: 51

Prepopulating grails app mysql database in cloud foundry

I need to prepopulate mysql database which is the backend for a Grails Application. This is working fine in local and I need to move to cloud foundry.

I used to prepopulate mysql database in local by executing sql. But now I need to prepopulate the mysql database which is cloud foundry service.

This is what I tried. I installed database migration plugin. Generated the changelog file without any data so that it contains only DDL statements. Then I inserted below code at end of changelog file.

 changeSet(author: "home (generated)", id: "1330581560176-85") {

          sqlFile( path: "config.sql")
   }          

Below is the entry for config.

grails.plugin.databasemigration.updateOnStart = true
grails.plugin.databasemigration.updateOnStartFileNames = changelog.groovy

My cloudfoundry app still starts with empty tables. Can anyone point me right direction.

UPDATE
I was able to do this. I was doing database migration wrongly. After reading http://blog.springsource.org/2011/08/17/countdown-to-grails-2-0-database-migrations/ properly I was able to get this working by putting sqlFile() in changelog.groovy file.

Upvotes: 0

Views: 449

Answers (1)

Mengu
Mengu

Reputation: 524

you can insert your code in the grails-app/cong/Bootstrap.groovy file and at the beginning of your app these codes will be executed.

Upvotes: 3

Related Questions