Search code examples
ruby-on-railsgrailsdatabase-migration

rails to grails - what happened to db:create and db:migrate?


I've got a fair bit of experience with Ruby on Rails, and I'm taking over development on an existing project created in Grails. The previous developer claims that anyone with Rails experience should be able to do just fine, but I'm banging my head against the wall...

I have the Grails environment correctly configured, and the app can connect to my database. If I were in a RoR project, I know I would just need to run 'rake db:create && rake db:migrate', and I'd be ready to go.

Is there a grails equivalent to bootstrap the database schema?


Solution

  • The default setting in DataSource.groovy of dbCreate = 'create-drop' will create the database tables after dropping previous tables. This works fine for initial development and ok while you're making rapid changes, but once things stabilize somewhat (and at the latest when you're going to production) install the http://grails.org/plugin/database-migration plugin to do proper migrations.

    The DSL will look familiar to a Rails developer, and there are convenient scripts that auto-generate migration scripts for you.