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

So, I’m attempting to use the tag in the root changelog file. I’m including the path in which I have subdirectories and a main .sql file that is calling multiple .sql scripts: i.e <<?xml version="1.1" encoding="UTF-8" standalone="no"?>

– note: inside this .sql file, it’s calling many other sql scripts. I also tried it w/o relativeToChangelogFile and w/o endDelimiter and still produced the same error.


  • when I execute from linux ./execute-patch --logfile=DEBUG update it errors out. Unexpected error running Liquibase: Error parsing line 10 column 60 of ./ChangeLog1212.xml : cvc - complex -type .3.2.2 : Attribute '…is not allowed to
    appear in element ‘sqlFile’.

  • I found this in the document but I’m not sure what it means: In using the Note: At this time, the <includeAll> tag cannot be used in an SQL formatted root changelog. What does this statement mean? Thank you for your help,

You cannot use sqlFile in a .sql changelog.

That means that your master or root changelog cannot be in sql format. It must be xml, yaml, or json. the master/root changelog is the driver file for your liquibase deployment.

1 Like

It looks like half my question got posted and lost during the akismet issue that I had during my post. My problem was with the includeAll tag but that problem was resolved due to a syntax error. Thanks for explaining the question that I had. VChamb

1 Like