Victor Rodriguez
Victor Rodriguez

Reputation: 85

liquibase sqlFile complains that "File does not exist"

So, a while back I moved all of our database functions and view to individual files for better change control. Today, I deleted a function and therefore I deleted the file for that function. However, the original changeLog from 2019.Q2.R1 still references the file and liquibase complains that the file does not exist now.

15:39:35 SEVERE 1/29/20 10:39 PM: liquibase: changelogs/catalog/catalog.db.changelog-2019.Q2.R1.xml::US122742.17::vrodrigu: File does not exist: 'functions/update_daily_take_ingest_date_func.sql'

We are following the best practice recommended by liquibase where we have a master changelog file that then includes all of changelog files, one for each new release. The file I deleted is still referenced by an old changelog file catalog.db.changelog-2019.Q2.R1.xml, which as the name implies is from Q2 of last year.

What is the best practice in these situations? Should a file referenced by old sqlFile elements just never be deleted? Should I go back to the old references and eliminate those references? The latter would be changing history and someone looking at that old changelog file wouldn't be the wiser. Is there a flag or attribute I can put on my changelogs so that they don't complain about the file not existing if it's deleted in the future?

Not sure what the best approach is. Thanks in advance for your help!

Upvotes: 1

Views: 1117

Answers (1)

htshame
htshame

Reputation: 7330

The best practice would be to write another changeSet in which you delete the function and add it to your project as a new file.

ChangeLogs and changeSets are supposed to be immutable. This idea is one of the corner stones of Liquibase-like tools. You are supposed only to add new changeSets to alter the existing database structure (even if the changeSets you're adding remove something).

Hence, altering or deleting existing changeSets (or changeLog files) is the opposite of best practice.

Upvotes: 1

Related Questions