Create column of type double precision[] with liquibase

断了今生、忘了曾经 提交于 2019-12-12 12:12:25

问题


How to create column of type double precision[] (array of doubles) with liquibase in postgresql database?

<changeSet id="add t_name table">
    <createTable tableName="t_name">
        ...
        <column name="doubleArray" type="???"/>
        ...
    </createTable>
</changeSet>

Google didn't help, please, if someone knows a solution, I will be very appreciative.


回答1:


I finally found the answer with help of my colleague. It seems that liquibase don't know such types, so we need to modify sql query manually:

<createTable tableName="t_name">
    ...
    <column name="doubleArray" type="DOUBLE_ARRAY"/>
    ...
</createTable>

<modifySql dbms="postgresql">
    <replace replace="DOUBLE_ARRAY" with="double precision[][]"/>
</modifySql>



回答2:


If you rely on Postgresql, you can use the float8 built-in alias:

<column name="doubleArray" type="float8[]"/>



回答3:


Liquibase 3.3.0 is able to generate precision for double type. e.g. "type=double precision[16][2]" generates double(16,2) in mysql.



来源:https://stackoverflow.com/questions/28240068/create-column-of-type-double-precision-with-liquibase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!