Plugins You can find out about all the publicly available Grails plugins.

Database migration tasks

  • Authors: Sam Pullara
0 vote
compile ":dbmigrate:0.1.5"




Using dbmigrate with Grails Installation

The best way to install it is to use

grails install-plugin

to add the functionality to your application.

The two scripts can now be executed like this:

grails create-migration

First this migrates your database to ensure that it is itself up to date. Then it will look at your database (using your datasource configuration) and determines the current version. It then creates a new


script within the grails-app/migrations/database name directory. You should then edit that file in order to do your change.

If you have no db_version table in the database you should create that table as the first order of business in the initial migration:

CREATE TABLE db_version (version integer NOT NULL)

Since even that syntax might be database specific I do not have it automatically create it for you.

grails migrate

This will attempt to automatically advance the configured database (looking at GRAILS_ENV and DataSource.groovy) to the most recent version available.


The dbmigrate plugin will allow you to track changes to your database over time and ensure that your database is always up-to-date with the code that is using it.