I’ve looked into Liquibase changesets
, customChange
, and contexts
, but after reading through materials these couple of days, I still haven’t found an answer that could help me accomplish what I want to do.
Basically, I have database change scripts that I want to run through Liquibase. This is what I have.
-
script1.sql
DROP MATERIALIZED VIEW LOG on TABLE1
-
script2.sql
DROP MATERIALIZED VIEW TABLE1
script1.sql
should be run on a certain DB1
, while script2.sql
should be run on a certain DB2
. The database URLs for DB1
and DB2
are:
-
DB1
:'jdbc:oracle:thin:@db_host:1521:DB1'
-
DB2
:'jdbc:oracle:thin:@db_host:1521:DB2'
I have the ff. defined in build.gradle
:
liquibase {
activities {
main {
changeLogFile "$projectDir/src/main/db/main-changelogs.xml"
url 'jdbc:oracle:thin:@db_host:1521:DB1'
username 'root'
password 'root'
}
}
}
My changelog is defined as follows:
<?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: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-4.0.xsd
http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-3.8.xsd">
<changeSet id="1" author="bob">
<sqlFile dbms="oracle"
path="my/path/script1.sql" />
</changeSet>
<changeSet id="2" author="bob">
<sqlFile dbms="oracle"
path="my/path/script2.sql" />
</changeSet>
</databaseChangeLog>
My question thus is, how do I switch connection between DB1
and DB2
within my changelog?