Use proper upsert for awarding achievements to avoid duplicate key errors
cgen-5db038e31ab84dcd92d09aa52e4a0291
This commit is contained in:
parent
caef767bf9
commit
2b8e99ca8e
1 changed files with 1 additions and 1 deletions
|
|
@ -214,7 +214,7 @@ export function createServer() {
|
|||
if (!rows.length) return res.json({ ok: true, awarded: [] });
|
||||
const { error: iErr } = await adminSupabase
|
||||
.from("user_achievements")
|
||||
.insert(rows, { upsert: true });
|
||||
.upsert(rows, { onConflict: "user_id,achievement_id" as any });
|
||||
if (iErr && iErr.code !== "23505")
|
||||
return res.status(500).json({ error: iErr.message });
|
||||
return res.json({ ok: true, awarded: rows.length });
|
||||
|
|
|
|||
Loading…
Reference in a new issue