报错信息

bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: ERROR: function uuid_generate_v4() does not exist

nested exception is org.postgresql.util.PSQLException: ERROR: function uuid_generate_v4() does not exist

是 uuid_generate_v4 这个函数不存在导致的。

导致这个问题的原因就是,uuid_generate_v4() 这个 uuid 函数默认的是在 Postgresql 扩展中的,数据库迁移后,extension 扩展就没有了,需要重新安装。

解决方案(是在sql查询中执行,不是命令行窗口):
sql查询中执行(注意是在)

CREATE EXTENSION pgcrypto;

另外,给PG添加uuid支持只需要在sql中运行

create extension "uuid-ossp"


检验函数:

select uuid_generate_v4()

Logo

一站式 AI 云服务平台

更多推荐