generateChangeLog

Description

I'm moving a mysql database into using LB. Some of the tables have constraints on tables that no longer exist. This caused "generateChangeLog" to emit a mystery error like so,

1 2 $ liquibase --changeLogFile f.xml --url "$DBI" generateChangeLog Unexpected error running Liquibase: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

I found that the following change allows generateChangeLog to complete.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 $ git diff diff --git a/liquibase-core/src/main/java/liquibase/change/ColumnConfig.java b/liquibase-core/src/main/java/liquibase/change/ColumnConfig.java index 144980b49..8ef52837f 100644 --- a/liquibase-core/src/main/java/liquibase/change/ColumnConfig.java +++ b/liquibase-core/src/main/java/liquibase/change/ColumnConfig.java @@ -143,6 +143,10 @@ public class ColumnConfig extends AbstractLiquibaseSerializable { if ((fk.getForeignKeyColumns() != null) && (fk.getForeignKeyColumns().size() == 1) && fk .getForeignKeyColumns().get(0).getName().equals(getName())) { constraints.setForeignKeyName(fk.getName()); + if(fk.getPrimaryKeyColumns().isEmpty()) { + System.err.println("WARNING AN EMPTY SET OF PRIMARY KEY CONSTRAINTS!!! Table: "+table.getName()+" pkc:"+fk); + continue; + } constraints.setReferences(fk.getPrimaryKeyTable().getName() + "(" + fk.getPrimaryKeyColumns().get(0).getName() +

Environment

OSX

Status

Assignee

Unassigned

Reporter

Robert Herrmann

Labels

None

Affects versions

3.5.5

Priority

Major
Configure