使用 Liquibase 创建 Postgres Varchar 数组列

Creating Postgres Varchar Array Columns with Liquibase

由于在列中使用数组更像是一种 NoSQL 而不是 RDBMS 存储列表的方式,我知道 Liquibase 并不正式支持该类型。但是,当我使用 docs 中的 PSQL 语句时,我得到以下信息:

<column name="widgets" type="varchar(8)[]" />

跟踪输出:

liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: ERROR: syntax error at or near "("
...
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "("

当从 PSQL 命令行 运行 时,不同的 DDL 按预期工作。

这一定是 PSQL 解析器中的一个错误。只需添加 space 即可修复。

<column name="widgets" type="varchar(8) []" />

Liquibase 必须以某种细微的方式更改 SQL 字符串。