Monday, September 16, 2013

GRAILS Liquibase migration - Add new column

Below code shows how to add a new column in an already existing table using GRAILS and liquibase
databaseChangeLog = {

 changeSet(author: "myname", id: "123456-1") {
  addColumn(tableName: "TABLE_NAME") {
   column(name: "NEW_DATE_COLUMN", type: "TIMESTAMP(6)",defaultValueDate: "2013-01-01") {
    constraints(nullable: "false")
   }
  }                
 }
 changeSet(author: "myname", id: "123456-2") {
  addColumn(tableName: "TABLE_NAME") {
   column(name: "COLUMN_NAME", type: "VARCHAR2(1020 BYTE)")
  }
 }
}