I am using .sql files for Liquibase changeset . In Pre deployment step , I am running few scripts like Disabled the Oracle jobs etc. When there is any error Liquibase Stop running next scripts.
In any case , I want run Post Deployment step scripts.
Is there any option in Liquibase for it ?
hotfix
March 27, 2024, 8:51am
2
You could just create the SQL scripts you need and have them be executed at the end of your master changelog?
changelog/master.xml
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd">
<!-- All your database object changelogs in correct order -->
<include file="src/sequence.xml" relativeToChangelogFile="true"/>
<include file="src/table.xml" relativeToChangelogFile="true" />
<include file="src/constraint_primary.xml" relativeToChangelogFile="true" />
<include file="src/constraint_foreign.xml" relativeToChangelogFile="true" />
<include file="src/constraint_unique.xml" relativeToChangelogFile="true"/>
<include file="src/constraint_check.xml" relativeToChangelogFile="true" />
<include file="src/index.xml" relativeToChangelogFile="true"/>
<include file="src/view.xml" relativeToChangelogFile="true" />
<include file="src/procedure.xml" relativeToChangelogFile="true" />
<include file="src/function.xml" relativeToChangelogFile="true"/>
<include file="src/package.xml" relativeToChangelogFile="true" />
<include file="src/package_body.xml" relativeToChangelogFile="true" />
<include file="src/trigger.xml" relativeToChangelogFile="true"/>
<include file="src/job.xml" relativeToChangelogFile="true"/>
<include file="src/program.xml" relativeToChangelogFile="true"/>
<!-- The below XML file would be a changelog containing scripts that are to be executed after every run -->
<include file="src/post.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>
changelog/src/post.xml
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd">
<!--
Your post deployment script, you could ofcourse add multiple.
Be aware of the runAlways, runOnChange and endDelimiter attributes!
-->
<changeSet author="john.doe" id="post_deployment_script.sql" runAlways="true" runOnChange="true">
<sqlFile path="/liquibase/changelog/path/to/your/post_deployment_script.sql"
relativeToChangelogFile="true" endDelimiter="/" />
</changeSet>
</databaseChangeLog>