How to tell Liquibase to map BLOB datatype to BYTEA on PostgreSQL?
It seems that Hibernate people has taken over and adapted the tool to their needs: https://liquibase.jira.com/browse/CORE-1863 , however, EclipseLink don't support oid's and the bug seems to be still open: https://bugs.eclipse.org/bugs/show_bug.cgi?id=337467
I need to use EclipseLink, and I need to use blobs with PostgreSQL. I'd like to use Liquibase, is it possible to make those things work together?
The storage size of blob data type in PostgreSQL is 1 to 4 bytes plus the string of actual binary, input format of blob data type is different in PostgreSQL. Below is the syntax : Create table name_of_table (name_of_column1 data_type, name_of_column2 data_type, name_of_column3 data_type, …, name_of_columnN bytea);
The bytea data type allows the storage of binary strings or what is typically thought of as “raw bytes”. Materialize supports both the typical formats for input and output: the hex format and the historical PostgreSQL escape format. The hex format is preferred.
You have two options.
If you only need this for Postgres and don't plan to support other DBMS, simply use bytea
as the column type.
Any data type that is not listed as one of the "generic" types in the description of the column tag will be passed "as-is" to the database, e.g.
<createTable tableName="foo">
<column name="id" type="integer"/>
<column name="picture" type="bytea"/>
</createTable>
If you want to support different DBMS, you can define a property depending on the DBMS:
<property name="blob_type" value="bytea" dbms="postgresql"/>
<property name="blob_type" value="blob" dbms="oracle"/>
then later
<createTable tableName="foo">
<column name="id" type="integer"/>
<column name="picture" type="${blob_type}"/>
</createTable>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With