How to execute a single .sql file that calls multiple scripts in one

Hi, I’m looking for help calling a postgresql .sql file inside liquibase changelog.

I’m using --formatted sql; changeset: --changeset author:id attribute1:value1

I would like to be able to have liquibase execute a single .sql script only once. Inside this xxxx.sql file it calls approximately 102 separate scripts (ea. script may perform diff functions (i.e create table, create views, triggers, etc.)). Is it possible for liquibase to execute 1 script that calls many? Or do I need to modify each postgresql script to include --liquibase formatted sql; --changeset author:id attribute1:value1? I see something similar in XML but no examples for sql.

Thank you, VCham

There is no ability to include files using the .sql format.

The easiest way to handle this scenario is to include them in an xml, yaml, or json master changelog, by either using an “include” for every file or includeAll (which requires the files to be in the correct execution order by file-name).

I was afraid you would say it could not be done. Unfortunately, my task is to use sql and as I have found – not to be best practice. Is it possible to mix liquibase changelog/formats (such as xml w/sql)? Thank you. VCham

Yes, you can absolutely mix changelog formats. The master changelog file has to be xml, yaml, or json, then you include changelogs of any format in the master.

1 Like

Good to know. Thank you. VChamb

1 Like