问题
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?
回答1:
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>
来源:https://stackoverflow.com/questions/42388886/force-liquibase-to-map-blob-to-bytea-on-postgresql