Quantcast
Channel: Liquibase Forums
Viewing all articles
Browse latest Browse all 2993

Re : Looking for feedback on cross-database support

$
0
0
We manage changelogs that are targeted against Oracle and Postgres and sometimes SQL Server. 

One thing that we had to take care of is Oracle's "char semantic". In order to ensure that VARCHAR(30) is indeed created as VARCHAR(30 Char) in Oracle we put the following at the start of each changelog:

  1.     <changeSet author="dba" id="char_semantics" dbms="oracle" runAlways="true">
            <sql>alter session set nls_length_semantics = 'CHAR'</sql>
        </changeSet>

Another thing that we do is to use properties e.g. to define columns for UUIDs:


  1.   <property name="uuid_function" value="uid.uuid_generate_v4()" dbms="postgresql"/>
      <property name="uuid_function" value="NEWID()" dbms="mssql"/>
      <property name="uuid_function" value="sys_guid()" dbms="oracle"/>

      <property name="uuid_type" value="uuid" dbms="postgresql"/>
      <property name="uuid_type" value="uniqueidentifier" dbms="mssql"/>
      <property name="uuid_type" value="RAW(32)" dbms="oracle"/>
     
      <changeSet author="arthur" id="1">
        <createTable tableName="foo">
          <column name="id" type="${uuid_type}" defaultValueComputed="${uuid_function}">
            <constraints nullable="false" />
          </column>
        </createTable>
      </changeSet>

The rules when Liquibase quotes object names are also not helpful. Consider e.g. the following:

    <createTable tableName="FooBar">

For Oracle Liquibase does not quote the table name and creates a table named FOOBAR. For Postgres Liquibase quotes the table name and thus a table with a quoted identifier is created "FooBar". For SQL Server the name is also not quoted. We finally created our own implementation of PostgresDatabase that only quotes names if they contain special characters or if they are reserved words. If you are interested, I am willing to share this implementation. I have seen some questions on Stackoverflow regarding this as well, so we are not the only ones.

Not really a DBMS topic, but: we run changelogs from the commandline and through Maven alike (depending on the developer and the environment). In that case the "current directory" is different which means that Liquibase will put a different value into the column "filename" of the databasechangelog table. Which in turn means that a second run of the changelog in a different environment will fail because the filename is part of the primary key of that table and Liquibase doesn't consider the changeSets as executed.

We wind up using "logicalFilePath" in all our changeLogs that only contains the filename, not the path and thus always uses the same value regardless of the environment. That however is error prone as it requires manual steps when creating new changelogs.

From my perspective, this (use the file name, not the full path) should be the default behavior of Liquibase.

Viewing all articles
Browse latest Browse all 2993

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>