0
votes

Trying to use liquibase-mongodb extension with Spring Boot, but running a migration has no effect on my database.

Added liquibase-core, liquibase-mongodb extension and ongo-java-driver as dependencies in a pom file.

Here is my changelog file:

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog 
    http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.0.xsd
    http://www.liquibase.org/xml/ns/dbchangelog-ext 
    http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

<changeSet id="first" author="andrei">
    <ext:createCollection collectionName="myCollection">
        <ext:options>
            {
            validator: {
            $jsonSchema: {
            bsonType: "object",
            required: ["name", "address"],
            properties: {
            name: {
            bsonType: "string",
            description: "The Name"
            },
            address: {
            bsonType: "string",
            description: "The Address"
            }
            }
            }
            },
            validationAction: "warn",
            validationLevel: "strict"
            }
        </ext:options>
    </ext:createCollection>
    </changeSet>
</databaseChangeLog>

I try to inject bean SpringLiquibase but it requires from me a DataSource, which is an interface, and mongo extension for liquidbase doesn't provide an implementation of this interface.

@Bean
public SpringLiquibase liquibase() {
    MongoLiquibaseDatabase db = new MongoLiquibaseDatabase();
    SpringLiquibase liquibase = new SpringLiquibase();
    liquibase.setChangeLog("classpath:/db/changelog/db.changelog-master.yaml");
    //How to do this?
    // liquibase.setDataSource();
    liquibase.setShouldRun(true);
    return liquibase;
}

Does anyone have a working example of the liquidbase mongodb extension with Spring?