Liquibase 1.9.x -> 2.0 Failure When Outputting to File

I’m running into a problem when I try to execute the following scenario.

  • Create a Liquibase project using Liquibase 1.9.5.
  • Run Liquibase against a blank database with the initial changelog file that.  Run all refactorings immediately (analogous to the 'update' command).
  • Add new changesets to the changelog file.
  • Upgrade to Liquibase 2.0
  • Run Liquibase against the database, but output the refactorings to file (analogous to the 'updateSQL' command).

When I attempt to walk through that scenario, I get an error that the “orderexecuted” column doesn’t exist in DatabaseChangelog.  It looks like what is happening is that Liquibase is dumping the changes necessary to DatabaseChangelog to the sql output file, but then attempting to read data from that column farther on in its operations.

Other than running a dummy changelog file directly against the database to keep the createUpdateScript method from failing later on, is there a good workaround for this?

    Exception in thread "main" liquibase.exception.DatabaseException: Error executing SQL SELECT FILENAME,AUTHOR,ID,MD5SUM,DATEEXECUTED,ORDEREXECUTED,TAG,EXECTYPE FROM DATABASECHANGELOG ORDER BY DATEEXECUTED ASC, ORDEREXECUTED ASC: DB2 SQL Error: SQLCODE=-206, SQLSTATE=42703, SQLERRMC=ORDEREXECUTED, DRIVER=3.57.82         at liquibase.executor.jvm.JdbcExecutor.execute(         at liquibase.executor.jvm.JdbcExecutor.query(         at liquibase.executor.jvm.JdbcExecutor.query(         at liquibase.executor.jvm.JdbcExecutor.queryForList(         at liquibase.executor.jvm.JdbcExecutor.queryForList(         at liquibase.executor.LoggingExecutor.queryForList(         at liquibase.database.AbstractDatabase.getRanChangeSetList(         at liquibase.database.AbstractDatabase.checkDatabaseChangeLogTable(         at liquibase.Liquibase.checkDatabaseChangeLogTable(         at liquibase.Liquibase.update(         at liquibase.Liquibase.update(         at com.docfinity.util.LiquibaseDBUpdater.createUpdateScript(         at com.docfinity.util.LiquibaseDBUpdater.main( Caused by: DB2 SQL Error: SQLCODE=-206, SQLSTATE=42703, SQLERRMC=ORDEREXECUTED, DRIVER=3.57.82         at         at         at         at         at         at         at         at         at         at         at         at         at         at         at liquibase.executor.jvm.JdbcExecutor$1QueryStatementCallback.doInStatement(         at liquibase.executor.jvm.JdbcExecutor.execute(         ... 12 more

I have reproduced this against DB2 and MS-SQL.  Included below is a stack trace from DB2.

I created to look into it more.  The problem is that there is code that is expecting columns added in 2.0 to be there during the processing of the updateSQL and they are not. 

For now, you will need to run a dummy changelog against the database or at least just run the alter table databasechangelog SQL generated by the dummy changelog against the database you need to run updateSQL against.