Add column with foreign key throws NPE


Running a migration with an <addColumn> that includes a foreign key in the constraints is throwing a NPE.

Attached a sample migration, below is the stacktrace I'm getting. If I move the foreign key to be added with addForeignKey everything works, but it's just more typing...

Caused by: java.lang.NullPointerException: null
at java.util.regex.Matcher.getTextLength(
at java.util.regex.Matcher.reset(
at java.util.regex.Matcher.<init>(
at java.util.regex.Pattern.matcher(
at liquibase.sqlgenerator.core.AddColumnGenerator.addForeignKeyStatements(
at liquibase.sqlgenerator.core.AddColumnGeneratorDefaultClauseBeforeNotNull.generateSql(
at liquibase.sqlgenerator.core.AddColumnGeneratorDefaultClauseBeforeNotNull.generateSql(
at liquibase.sqlgenerator.SqlGeneratorChain.generateSql(
at liquibase.sqlgenerator.SqlGeneratorFactory.generateSql(
at liquibase.executor.AbstractExecutor.applyVisitors(
at liquibase.executor.jvm.JdbcExecutor.access$000(
at liquibase.executor.jvm.JdbcExecutor$1ExecuteStatementCallback.doInStatement(
at liquibase.executor.jvm.JdbcExecutor.execute(
at liquibase.executor.jvm.JdbcExecutor.execute(
at liquibase.database.AbstractJdbcDatabase.execute(
at liquibase.database.AbstractJdbcDatabase.executeStatements(
at liquibase.changelog.ChangeSet.execute(
at liquibase.changelog.visitor.UpdateVisitor.visit(
at liquibase.Liquibase.update(
at liquibase.integration.spring.SpringLiquibase.performUpdate(
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(


OS X 10.8
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b40)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b55, mixed mode)
Spring 3.2.4


Per Abich
December 3, 2013, 2:59 PM

Try this:

Per Abich
December 3, 2013, 3:02 PM

I guess the documentation is a little unclear on this and the tag names really don't make it clearer... I guess it should rather be either or, not one variant throwing a NPE...

Nathan Voxland
December 5, 2013, 2:43 PM

Fixed addColumn to respect referencedTableName and referencedColumnNames attributes

Łukasz Pogorzelski
September 24, 2014, 9:41 AM

Version 3.0.4 is affected too.



Nick Stuart

Fix versions

Affects versions