walinejs / waline

💬 A Simple, Safe Comment System
https://waline.js.org/en/
GNU General Public License v2.0
2.27k stars 396 forks source link

[Bug]: duplicate key value violates unique constraint "wl_comment_pkey" #2701

Closed zhuozhiyongde closed 2 months ago

zhuozhiyongde commented 2 months ago

问题描述 | Describe the bug

我原先使用其他非 valine 的评论系统,尝试迁移到 waline,已根据表的结构尝试恢复了数据,并且成功插入,但当我在 waline 发布新评论新时,出现此报错。

问题网站 | Website URL

https://waline.arthals.ink

服务部署在哪里? | Where your waline deploy?

Vercel (Default)

数据存储在哪里?| Where your comment data store?

PostgreSQL


Problem description | Describe the bug

I originally used other non-valine comment systems and tried to migrate to waline. I tried to restore the data according to the table structure and successfully inserted it. However, when I published a new comment in waline, this error occurred.

Question Website | Website URL

https://waline.arthals.ink

Where is the service deployed? | Where your waline deploy?

Vercel (Default)

Where is the data stored? | Where your comment data store?

PostgreSQL

zhuozhiyongde commented 2 months ago

问 GPT 解决了:

-- 获取当前表中最大的 id 值
SELECT MAX(id) FROM wl_comment;

-- 假设最大 id 值为 1000
-- 设置序列的当前值为 1000
ALTER SEQUENCE wl_comment_seq RESTART WITH 1001;