强制Liquibase在PostgreSQL上将Blob映射到BYTEA [英] Force Liquibase to map Blob to BYTEA on PostgreSQL
问题描述
如何告诉Liquibase在PostgreSQL上将BLOB数据类型映射到BYTEA?
How to tell Liquibase to map BLOB datatype to BYTEA on PostgreSQL?
似乎Hibernate员工已经接管了该工具并对其进行了调整以满足他们的需求: https://liquibase.jira.com/browse/CORE-1863 ,但是,EclipseLink不支持oid,并且该错误似乎仍然处于打开状态:
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
我需要使用EclipseLink,并且需要在PostgreSQL中使用blob.我想使用Liquibase,是否可以使这些东西协同工作?
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?
推荐答案
您有两个选择.
如果您只需要Postgres而不打算支持其他DBMS,只需使用 bytea
作为列类型.
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>
如果要支持其他DBMS,则可以根据DBMS定义属性:
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"/>
然后再
<createTable tableName="foo">
<column name="id" type="integer"/>
<column name="picture" type="${blob_type}"/>
</createTable>
这篇关于强制Liquibase在PostgreSQL上将Blob映射到BYTEA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!