I’m sure there’s got to be an easy way to do this, but I couldn’t find it in the docs for the life of me.
How do I output/log the actual SQL statements that Liquibase generates and runs against the db?
Thanks,
Evan
I’m sure there’s got to be an easy way to do this, but I couldn’t find it in the docs for the life of me.
How do I output/log the actual SQL statements that Liquibase generates and runs against the db?
Thanks,
Evan
Well, I worked around this with this for now:
public void printSql()
{
try {
Connection c = getDataSource().getConnection();
Liquibase liquibase = createLiquibase©;
PrintWriter pw = new PrintWriter(System.out);
liquibase.update(getContexts(), pw);
} catch (SQLException e) {
e.printStackTrace();
} catch (LiquibaseException e) {
e.printStackTrace();
}
}
Instead of running “update” you can also run “updateSQL” which will output the SQL to be executed. You can also use --logLevel=DEBUG when you run update and it should output the SQL as part of the debug log.
Nathan