I have a PostgreSQL database in which tables reference each other across schema boundaries. I tried using the Ant task generateChangeLog to create a change log from the database, but it failed because some of the foreign keys for tables in the public schema referenced tables in a different schema that were not part of the change log. I finally figured out that I could set defaultschemaname to “%” to get the Ant task to include tables in all schemas. The only problem was that the code kept bombing on SqlDatabaseSnapshot.readColumns() where the code calls isColumnAutoIncrement(). The problem was that, rather than using the table’s schema name, the code was using the default schema name passed in from the Ant task and trying to prepend this string (in this case, “%”) to the table name. The code knows the schema of the table; all that is needed is to pass this value to the isColumnAutoIncrement, rather than the default schema name. The patch for 1_9_5 is below. It looks like the same problem exists in 2.0.
Thanks for the great project!
Andrew
Index: src/java/liquibase/database/structure/SqlDatabaseSnapshot.java
— src/java/liquibase/database/structure/SqlDatabaseSnapshot.java (revision 1283)
+++ src/java/liquibase/database/structure/SqlDatabaseSnapshot.java (working copy)
@@ -273,7 +273,7 @@
}
} else {
columnInfo.setTable(table);
- columnInfo.setAutoIncrement(database.isColumnAutoIncrement(schema, tableName, columnName));
+ columnInfo.setAutoIncrement(database.isColumnAutoIncrement(schemaName, tableName, columnName));
table.getColumns().add(columnInfo);
}