Joh*_*ith 7 postgresql json hstore
我正在尝试编写一个迁移以将现有 hstore 列转换为 JSON(不是 JSONB)。
我尝试了不同的解决方案json USING cast(hstore_column as json),在 github 上找到了一些功能,但没有真正解决问题。
主要问题是没有直接转换,其次是即使我将列转换为文本作为中间步骤,我也需要将默认列值更改为 json。
有人已经这样做了吗?
你可以简单地使用
alter table my_table alter column h_store_column type json using hstore_to_json(h_store_column)
Run Code Online (Sandbox Code Playgroud)
当然,您需要首先删除与 json 数据类型不符的列上设置的所有默认值。