DATABASECHANGELOGLOCK and DATABASECHANGELOG tables

In our application there are four database (MS SQL SERVER) namely

  1. db1
    2.db2
    3.db3
    4.db4

While connecting to SQL using liquibase we use db2 in connection string and then perform deployment.
As db2 is used in connection string DATABASECHANGELOGLOCK and DATABASECHANGELOG are created in db2 database.
As a part of deployment, every sql script has database name at the start like

  1. Script1.sql
    Use db1
    GO
    —update/delete statements
    GO

  2. Script2.sql
    Use db2
    GO
    —update/delete statements
    GO

  3. Script3.sql
    Use db3
    GO
    —update/delete statements
    GO

  4. Script4.sql
    Use db4
    GO
    —update/delete statements
    GO

If the last script in the deployment is db2 (as it is specifed in the connection string and the DATABASECHANGELOGLOCK and DATABASECHANGELOG) are created in db2 database.
then the deployment succeeds

But if the last script is of some other database (other than db2) it gves error
liquibase.exception.LockException: liquibase.exception.LockException: Did not update change log lock correctly.

Seems it goes to search the DATABASECHANGELOGLOCK and DATABASECHANGELOG in the database in which last script is deployed.

How I can handle this ?

1 Like

Hey, @Dinesh1 - thanks for posting this issue. I am researching to try to find an answer for you. When we have something to share, I or one of my teammates will reply again to follow up.

Regards,
Tabby

There is a multi-catalog project setup example in the Liquibase Toolbox repository. I highly recommend that you check it out! Also, feel free to contribute!

1 Like