Liquibase - execute multiple pl/sql packages

1.1k Views Asked by At

Good morninng, I'm create my Liquibase changelog to be able to deploy Oracle object with one click.

In my projects we have many packages that we save in the file system as pkb/pks (but we can save them as sql as well) ..

I'd like to configure liquibase to execute ALWAYS the package files eachtime I run the task.

I found the tag includeALL .. but this will execute only once the files belong the path ..

how can i do to execute them every time?

I tried something like this

<changeSet id="01f11a6b-a473-4edc-bcc7-acfa802f4b48" author="deployment" runAlways="true">
    <includeAll path="${url}/Database_Objects/"/>
</changeSet>

but i got error..

Thx for the help

Liquibase version

dependencies {
    classpath "org.liquibase:liquibase-core:3.4.1"
    classpath "org.liquibase:liquibase-gradle-plugin:1.1.1"
    classpath "com.oracle:ojdbc6:11.2.0.4"
}

note: I'm running liquibase via Gradle /IntelliJ

3

There are 3 best solutions below

1
On

<includeAll> and <include> tags cannot be enclosed in the changeSet tag which has runAlways attribute.To achieve running the sql files always you need to look for following tag. SqlFile tag

0
On

Thankds for your comment .. unfortunately it does not give the solution :( I need to execute several sql file containing package declaration ..

I have even tried to merge all file in one ..but still getting

"Caused by: java.sql.SQLSyntaxErrorException: ORA-00900: invalid SQL statement" when I tried to exec

Here what I put on the changelog

<changeSet  author="deployment"  id="d4ad73ec-8fd4-4d4c-8590-b6ed9eec609f" runAlways="true" context="Fix">
    <sqlFile  dbms="oracle"
              encoding="UTF-8"
              endDelimiter="/\n"
              path="${url}/50_db_objects.sql"
              relativeToChangelogFile="false"
              splitStatements="true"
              stripComments="false"/>
</changeSet>

then in 50_db_objects.sql I have something like that

create or replace package body xxxxx as
.....
end xxxxx ;
/
    
    
create or replace package body xxxxx2 as
.....
end xxxxx2 ;
/
0
On

Try to set splitStatements="false" in Your changeset declaration. By setting "true" You are telling to liquibase that it should execute each command separately and those are separated by ";" as default.

<changeSet  author="deployment"  id="d4ad73ec-8fd4-4d4c-8590-b6ed9eec609f" runAlways="true" context="Fix">
    <sqlFile  dbms="oracle"
              encoding="UTF-8"
              endDelimiter="/\n"
              path="${url}/50_db_objects.sql"
              relativeToChangelogFile="false"
              splitStatements="false"
              stripComments="false"/>
</changeSet>