Specifying database schema when instantiating Liquibase with Spring

Hi, we’re using the following to start Liquibase from Spring:


The problem we’re running into is that in some cases our application will run in a different database schema than the “default” one (i.e. the one with the same name as the datasource’s connecting username). I can’t figure out a way to pass a schema name to Liquibase via Spring.

It looks like the SpringLiquibase class does not support setting the defaultSchema currently.  You should be able to subclass SpringLiquibase and override the createLiquibase() method to call super.createLiquibase() then call setDefaultSchema(YOUR_SCHEMA) on the object returned from the superclass call.

I’ll add a defaultSchema property to the class for the next release.


Sorry, it is on createDatabase().  It should be:

        protected Database createDatabase(Connection c) throws DatabaseException {         Database database = super.createDatabase(c);         database.setDefaultSchemaName(YOUR SCHEMA);         return database;     }


Hmm the SpringLiquibase.createLiquibase method is private and there doesn’t appear to be a createDatabase method in the SpringLiquibase class.

I’m on version 1.9.4

Sorry, I had just looked at the 2.0 codebase. 

It will probably be easiest for you to just copy/paste the default SpringLiquibase method and modify it to fit your needs.  I’m not sure if there will be another 1.9 release or not to make the change in the codebase.