postgreSQL error: "constraint does not exist" (but it does exist...)

postgreSQL error: "constraint does not exist" (but it does exist...)

我有一个正在尝试更新的数据库,但我不明白为什么我会收到有关列不存在的奇怪错误。当我使用 'heroku pg:psql' 访问数据库时,我完全可以看到该列。我发现 other questions 有类似的问题,但未能解决它。

这是我执行 INSERT...ON CONFLICT WITH CONSTRAINT...有什么想法吗?

const text = 'INSERT INTO "test2" '
+'(route_id, secupdated, retrievedate, traintimeday) '
+'VALUES(, , , ) '
+'ON CONFLICT ON CONSTRAINT traintimeday '
+'DO UPDATE SET (secupdated, secarrival) = (excluded.secupdated, excluded.secarrival) '
+'RETURNING *' ; 
const values = [train_id 
, Math.round(dateNow.getTime()/1000)
, Math.round(dateNow.getDate())
, Math.round(dateNow.getDate()) + stu.stop_id
]; 
pool.query(text, values, (err, res) => {
if (err) {
throw err;
}
console.log('user:', res.rows[0])
})

错误消息说 'constraint traintimeday does not exist'

如果traintimeday不是一个约束,而不是:

+'ON CONFLICT ON CONSTRAINT traintimeday '

使用:

+'ON CONFLICT (traintimeday) '