In our application there are four SQL Server databases:
db1
db2
db3
db4
While connecting to SQL Server 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
Script1.sql
USE db1
GO
—update/delete statements
GO
Script2.sql
USE db2
GO
—update/delete statements
GO
Script3.sql
USE db3
GO
—update/delete statements
GO
Script4.sql
USE db4
GO
—update/delete statements
GO
If the last script in the deployment is db2 (as it is specified 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) I get an 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?