Validate only with Spring integration

I am not familiar with the Spring integration, but on the command line there is a status command that returns the number of changesets that need to be run.

Steve Donie
Principal Software Engineer
Datical, Inc.

Thanks for the pointer. I had a look at how that works and implemented a solution based on it. I’ve sent a pull request ( but I’m using a subclassing approach in the mean time:

public class SpringLiquibase extends liquibase.integration.spring.SpringLiquibase {

    private boolean validateOnly = false;

    public boolean isValidateOnly() {

        return validateOnly;


    public void setValidateOnly(boolean validateOnly) {

        this.validateOnly = validateOnly;



    public void afterPropertiesSet() throws LiquibaseException {

        ConfigurationProperty shouldRunProperty = LiquibaseConfiguration.getInstance()

                .getProperty(GlobalConfiguration.class, GlobalConfiguration.SHOULD_RUN);

        if (!shouldRunProperty.getValue(Boolean.class)) {


                    .info("Liquibase did not run because "

                            + LiquibaseConfiguration.getInstance().describeValueLookupLogic(shouldRunProperty)

                            + " was set to false");



        if (!shouldRun) {

            LogFactory.getLogger().info("Liquibase did not run because 'shouldRun' " + "property was set to false on "

                    + getBeanName() + " Liquibase Spring bean.");



        if (validateOnly) {

            Connection c = null;

            Liquibase liquibase = null;

            try {

                c = getDataSource().getConnection();

                liquibase = createLiquibase(c);

                if (liquibase.listUnrunChangeSets(new Contexts(contexts), new LabelExpression(getLabels()))

                        .size() > 0) {

                    throw new LiquibaseException("Unrun changes found in validate only mode");


            } catch (SQLException e) {

                throw new DatabaseException(e);

            } finally {

                Database database = null;

                if (liquibase != null) {

                    database = liquibase.getDatabase();


                if (database != null) {




        } else {





When we use hibernate in production we specify “validate” as the DDL command, so that if we deploy an app it will check that the database is in the expected state, and if it isn’t, then it’ll throw an exception and stop the application startup. Then the sysadmin can look into what changes need to be applied.

We’d like to do the same thing with Liquibase, and using the Spring integration seems to be the obvious place to do it, but I can not find any reference to this kind of functionality. Does it exist, and if not, is there a method that would return a flag to say if changes are required?