change execution listener

Hi,


I’m looking for something to solve the following: We use liquibase to manage initial values for our application. Now when upgrading a database we would like to generate a list of insert statements that have effectively been run against the database (that were not skipped due to preconditions or other conditions).


Is there a way for this using liquibase?


I was thinking of a listener that can be registered with Liquibase and that is notified on some points during changeset processing… would this then be a reasonable enhancement?


Thanks in advance!

Regards,
Eike


There is the updateSQL mode, but that does not handle preconditions on changeSets. In 2.0, there is logLevel=DEBUG which will log the SQL ran, although you get a lot of other information that you are not interested in.


With the 2.0 extension system (liquibase.org/extensions) you can register a custom database class that overrides the execute() method (or a method similar to that) which will log the SQL as well. If you are only interested in the SQL for certain changes, you could register custom versions of them that output the SQL when executed.


Nathan

Hi Nathan,


thank you for your fast reply and the hint. I think using a custom Database class sounds good, I will try this.


best regards,

Eike

Hi,


I ran into a problem regarding DatabaseFactory class. The register method takes an object of type Database as argument. This and the last lines at http://liquibase.jira.com/wiki/display/CONTRIB/Database made me think, that the same instance is reused:

Threading/Singleton notes

  • returnDatabase = foundDatabases.iterator().next().getClass().newInstance();
  • Maybe the same instance of Database cannot be reused because of some conflicting state. But why is regiser() not taking a Class<? extends Database>-object as argument? 


    My problem now is that I like to inject some listeners and services into my database from an IOC framework (hivemind/hiveapp). Thats why I’m registering an instance of my Database at liquibase.DatabaseFactory. But this does not work right now. 


    I would go and patch DatabaseFactory to return the same instance as registered, what do you think?


    Btw, I’m currently using liquibase 2.0.2-SNAPSHOT from tunk (r2067)


    regards,

    Eike

    I think it’s good to patch DatabaseFactory to return the same instance. The reason register takes an object not the class is because we do use instances of the database classes to check for whether it should respond to a given url. It would be fine to add another register() method that takes Class<? extends Database> as well for convencience


    Nathan