Database migration tasks

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

 Documentation

Summary

Installation

Using dbmigrate with Grails Installation

The best way to install it is to use

grails install-plugin grails-dbmigrate-0.1.zip

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

migratefromN.sql

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.

Description

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.