SQL Tips

Deleting a bad changelog in Liquibase

Identify the change set you need to remove (to run again)

<changeSet author=“me” id=“2.1.0-x-table”>
<sqlFile path=“/mycustomsql.sql”
relativeToChangelogFile=“false” stripComments=“true” />
</changeSet>

2 – As your db instance owner, remove the change log entry

[db2inst1@db myfolder]$ db2 “DELETE from myschema.DATABASECHANGELOG WHERE ID = ‘2.1.0-x-table'”
DB20000I The SQL command completed successfully.

3 – Confirm the change log is removed

[db2inst1@db myfolder]$ db2 “select * from myschema.DATABASECHANGELOG WHERE ID = ‘2.1.0-x-table’”

Dump Change Log Checksum in Liquibase

I lost my changelog tables and the lock table for Liquibase

I was able to Dump Change Log in Liquibase, and then load the resulting inserts into the changelog.