Reputation: 15
I'm using liquibase with oracle and postgres and I would like to use the changeLog properties to customize the elements of the changeSets that are different in the two databases.
I'm using the example from https://www.liquibase.org/documentation/changelog_parameters.html.
Here is my db-changelog.xml
<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"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<property name="table.name" value="table_O" dbms="oracle"/>
<property name="table.name" value="table_P" dbms="postgres"/>
<property name="column1.name" value="column1_O" dbms="oracle"/>
<property name="column1.name" value="column1_P" dbms="postgres"/>
<property name="column2.name" value="column2_O" dbms="oracle"/>
<property name="column2.name" value="column2_P" dbms="postgres"/>
<property name="clob.type" value="blob" dbms="oracle"/>
<property name="clob.type" value="bytea" dbms="postgres"/>
<changeSet id="1" author="joe">
<createTable tableName="${table.name}">
<column name="id" type="int"/>
<column name="${column1.name}" type="${clob.type}"/>
<column name="${column2.name}" type="int"/>
</createTable>
</changeSet>
</databaseChangeLog>
The command
$ liquibase --driver=oracle.jdbc.OracleDriver \
--classpath=ojdbc8-18.3.0.0.jar \
--changeLogFile=db.changelog.test.xml \
--url=jdbc:oracle:thin:@localhost:1521/my_db \
--username=my_user \
--password=my_pwd \
--logLevel debug updateSQL > simple_changeLog_ORACLE.sql
works fine and I obtain the changelog for oracle, but the command
$ liquibase --driver=org.postgresql.Driver \
--classpath=postgresql-42.2.5.jar \
--changeLogFile=db.changelog.test.xml \
--url=jdbc:postgresql://localhost:15432/my_db \
--username=my_user \
--password=my_pwd \
--logLevel debug updateSQL > simple_changeLog_POSTGRES.sql
fails with following exception
java.lang.ArrayIndexOutOfBoundsException: 1
at liquibase.datatype.DataTypeFactory.fromDescription(DataTypeFactory.java:251)
at liquibase.change.core.CreateTableChange.generateStatements(CreateTableChange.java:70)
at liquibase.change.AbstractChange.generateStatementsVolatile(AbstractChange.java:287)
at liquibase.change.AbstractChange.warn(AbstractChange.java:358)
at liquibase.changelog.visitor.ValidatingVisitor.visit(ValidatingVisitor.java:110)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:83)
at liquibase.changelog.DatabaseChangeLog.validate(DatabaseChangeLog.java:284)
at liquibase.Liquibase.update(Liquibase.java:198)
at liquibase.Liquibase.update(Liquibase.java:274)
at liquibase.Liquibase.update(Liquibase.java:251)
at liquibase.integration.commandline.Main.doMigration(Main.java:1433)
at liquibase.integration.commandline.Main.run(Main.java:229)
at liquibase.integration.commandline.Main.main(Main.java:143)
The option --logLevel debug shows a difference in the parsed changeSet.
The oracle one is
17:59:43.184 DEBUG [liquibase.util.MD5Util]: Computed checksum for createTable:[
columns=[
[
name="id"
type="int"
],
[
name="column1_O"
type="blob"
],
[
name="column2_O"
type="int"
]
]
tableName="table_O"
] as 836321c599b350ca366cc6ea3bde3890
while the postgres one is
17:51:55.864 DEBUG [liquibase.util.MD5Util]: Computed checksum for createTable:[
columns=[
[
name="id"
type="int"
],
[
name="${column1.name}"
type="${clob.type}"
],
[
name="${column2.name}"
type="int"
]
]
tableName="${table.name}"
] as 71476a8361010689730a8bf91f8d7115
Am I missing something?
Upvotes: 1
Views: 1418
Reputation: 9016
I think the only issue is that the value to use for postgres is postgresql
rather than just postgres
.
The list of database names is at https://www.liquibase.org/databases.html
Upvotes: 1