External API invocation from liquibase

I am using liquibase to do the DB deployments in our projects. we are getting the changeset details stored in a changelog table at that database level. since we are using the liquibase in all the projects in our firm, i want to have the changelog records to be saved in a central database at firm level. do we have any option to invoke an API while saving the change log record into the local database?

we can implement an api to accept the changelog record and store it in a central database, so that i can use that single database as source of truth for any DB schema level changes in the firm.

Appreciate any lead in this idea!

Malli Chandana

In this case, I would recommend taking the Managing Liquibase Changelogs (LB203) free course from Liquibase University. That will teach you best practices for managing changelogs in different use cases. There’s also some useful information about such best practices in our documentation: Getting Started | Liquibase Best Practices | Liquibase.org

Create an API for Centralized Storage:
Set up an API that accepts changelog records and stores them in the central database. You can implement this API using a framework like Spring Boot, Express.js, or any other technology stack of your choice.

Custom Liquibase Extension:
Create a custom Liquibase extension that intercepts the changelog recording process and invokes your API. This extension will be responsible for sending changelog data to your central database API.

Configure Liquibase:
Modify your Liquibase configuration to include your custom extension. You’ll need to provide details about when and how your extension should run. Typically, this involves specifying a custom listener.

Modify Changelog Files:
Adjust your existing Liquibase changelog files to include a call to your custom extension at the appropriate point in the changelog. You might want to add a custom change type or use the tag to trigger the extension.

Test and Deploy:
Test your setup thoroughly to ensure that changelog records are correctly sent to the central database through your API. Once you’re confident in the setup, deploy it across your projects.

Here’s a simplified example of what your custom Liquibase extension might look like in Java:
import liquibase.changelog.ChangeSet;
import liquibase.changelog.DatabaseChangeLog;
import liquibase.changelog.visitor.AbstractChangeLogVisitor;
import liquibase.exception.LiquibaseException;

public class CentralizedChangelogExtension extends AbstractChangeLogVisitor {

private final CentralDatabaseApi centralApi;

public CentralizedChangelogExtension(CentralDatabaseApi centralApi) {
    this.centralApi = centralApi;

public void visit(ChangeSet changeSet, DatabaseChangeLog databaseChangeLog, DatabaseChangeLog.RunStatus runStatus) throws LiquibaseException {
    // Extract changelog details from changeSet
    String changeLogRecord = createChangeLogRecord(changeSet);

    // Send changelog record to central API