Executing JS script file from liquibase mongoDB changeset

I want to integrate liquibase into our db as a version control tool, we are using Java with spring(not boot with beans)
the following link shows how we can execute liquibase schema changes:

We are using mongodb and I saw that there is a new driver called liquibase mongo(on maven).

however we are running the schema changes from js script files,
Is that possible to execute js file using liquibase-mongo? I know for sql you have a tag with the script location in it
Many thanks,

1 Like

One more issue:
the java class in the readme file:

it is not lined up with 4.1.1 mongoDB liquibase version,
can you please update the guide? (a full working example would be amazing !! :slight_smile: )

Hi @roie!

To answer your question above, when your changeset points to a script, it is looking for valid sql that would be valid if you were to run it directly against the db platform. A js script would not work but, liquibase can take sql and run it b/c it just opens a jdbc connection to the target db, and executes sql.

Originally, I believe you are trying to version your db changes. If you create sql, or sql changelogs and save them in a directory structure in your repo, those scripts will be versioned. The database maintains its individual version level in its databasechanglelog table.



I may have not explained myself currectly
In a Mongo db change set, As a follow up, I have the following function:

function createNewTibcoConfig(oldConfig) {
    const newObject = {"a": "blabla"};
    if (condition) {
        //do something with newObject 
    } else { 
		//do something else with newObject 
	db.collection.update({ _id: newObject._id }, { $set: { "oldConfig": newObject } });

How can Execute the following function(or only content of function) in an changeSet xml file?

<changeSet id="1" author="bob">
 <!--How can I execute the content of the function here? is it possible? keep in mind there is an if condition in the function -->