Background: we have the Grails 1.3.7 application and we use Liquibase to manage database migrations.
I am trying to add a new column to an existing table that is not empty.
My set of changes looks like this:
changeSet(author: "someCoolGuy (generated)", id: "1326842592275-1") { addColumn(tableName: "layer") { column(name: "abstract_trimmed", type: "VARCHAR(455)", value: "No text") { constraints(nullable: "false") } } }
Which was supposed to insert the value "Without text" in every existing row and, therefore, satisfied a non-zero restriction. Liquibase Add Column Docs .
But when applying migration change sets, I get the following exception:
liquibase.exception.DatabaseException: Error executing SQL ALTER TABLE layer ADD abstract_trimmed VARCHAR(455) NOT NULL: ERROR: column "abstract_trimmed" contains null values
Which seems to me that it does not use the value attribute.
If I change my set of changes to work, look as follows, I can achieve the same. But I do not want (and should not) do it.
changeSet(author: "someCoolGuy (generated)", id: "1326842592275-1") { addColumn(tableName: "layer") { column(name: "abstract_trimmed", type: "VARCHAR(455)") } addNotNullConstraint(tableName: "layer", columnName:"abstract_trimmed", defaultNullValue: "No text") }
Does Liquibase really ignore my value attribute or is something else happening here that I don't see?
I am using Grails 1.3.7, Database-migration 1.0 plugin, Postgres 9.0
sql postgresql database-design grails liquibase
David
source share