報錯信息
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查詢中執行
CREATE EXTENSION pgcrypto;
即可
另外,給PG添加uuid支持只需要在sql中運行
create extension "uuid-ossp"
檢驗函數:
select uuid_generate_v4()