Add defaultSchema parameter to Servlet Listener because of bug with DB2 database if currentSchema connection parameter is set
Description
Environment
None
Activity
Show:
Nathan Voxland April 29, 2010 at 4:28 AM
Added check for LIQUIBASE_DEFAULT_SCHEMA web.xml parameter
Nathan Voxland August 21, 2009 at 2:39 PM
A workaround was found in http://liquibase.org/forum/index.php?topic=117.msg472#msg472
May need to document or manage it better in code, though.
Actually was thinking the issue should be categorised as a bug, but left it as a feature for now since the bug looks more related to DB2.
When using the Servlet Listener against a DB2 database where the app server has the connection property of currentSchema set, liquibase falls over with an attempt to create the DatabaseChangeLog twice.
The reason it happens can be tracked down to the
AbstractDatabase.checkDatabaseChangeLogTable()
method. In here there is a call toconnection.getMetaData().getColumns(convertRequestedSchemaToCatalog(getDefaultSchemaName()), convertRequestedSchemaToSchema(getDefaultSchemaName()), getDatabaseChangeLogTableName(), null)
. The call togetDefaultSchemaName()
will instruct DB2 to explicitly look for the table in the currently logged on user's schema.Later when the tables are created again no schema is specified in the creation statement so the currentSchema connection setting kicks in and the table is created in the default schema specified in the setting.
On the next run, the call above checks for the tables in the connection ID's schema, doesn't find it, creates the table and gets the duplicate object error from the database.
If I get some time I'll upload a patch.