Skip to Main Content

SQLcl: MCP Server & SQL Prompt

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Passing subst variables to liquibase changelogs

krow7Sep 1 2021

Hi!
It would be a nice feature for SQLcl being able to pass subst variables to liquibase changelogs. See what I mean.
File test.sql:

define table_name = shipping_log
lb update -changelog controller.xml

File controller.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"
  xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
                      http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
    <changeSet author="me" id="table.sql">
      <sqlFile endDelimiter=";"
               path="table.sql"
               relativeToChangelogFile="true"
               splitStatements="true"
               stripComments="false"/>
    </changeSet>
</databaseChangeLog>

File table.sql:

create table ${table_name} (
	id		number,
	created	        date,
	value	        varchar2(4000)
);

So when we call sql orders/orders@mydb @test.sql we deploy table with a given name (shipping_log).
In a native liquibase it is possible to use property tag (https://docs.liquibase.com/concepts/basic/changelog-property-substitution.html) to substitute values.

Comments
Post Details
Added on Sep 1 2021
0 comments
1,322 views