How to make liquibase use an existing table

I am using liquibase directly in Java.

I am setting a change log table name as I have an existing table I want to use.

Liquibase fails to create a snapshot from existing table and tries to create the same table again. This of course fails as the object already exists,

Using liquibase version: 3.7.0

This sounds like a fairly technical issue. What mechanism are you using to set the change log table name?

I’m not clear what you mean by “Liquibase fails to create a snapshot from existing table” - I assume you are trying to basically run liquibase update, but that command doesn’t take a snapshot, it just looks at the databasechangelog table and at your changelog.

Are you able to debug into your code and into Liquibase? If so, I would set some breakpoints in Liquibase in the StandardChangeLogHistoryService to see whether it is using your custom change log table as expected or not.

If you have some snippets of code or other artifacts to share I might be able to help more. 

Steve Donie
Principal Software Engineer
Datical, Inc.

Hi Steve,

I set the custom name using the setDatabaseChangeLogTableName on the Database Object.

Regarding the snapshot, I see using debug that during the database.update run it tries to initialize the ChangeLogHistoryService interface - specifically using StandardChangeLogHistoryService.

In the standard impl - during the init service api it looks up a snapshot, doesn’t find it and issues a create query.

Specifically, changeLogTable is returned as null and hence liquibase tries to create the table although in relity it exists: