仅更改子域名时 Rebake 失败

你好

我最近将生产环境的 /shared 数据库文件夹复制到了预发布服务器(以使两个环境保持一致)。

我意识到链接仍指向之前的域名,因此我遵循了这份 指南

在容器内运行此命令时:

discourse remap forums.coretabs.net discourse.coretabs.net

我收到了一个“重复键值”错误:

正在重写 forums.coretabs.net 到 discourse.coretabs.net 的所有出现
此任务将重写数据,您确定吗(输入 YES)
YES
错误:ERROR:  duplicate key value violates unique constraint "index_incoming_domains_on_name_and_https_and_port"
详细信息:Key (name, https, port)=(discourse.coretabs.net, t, 443) 已存在。
由于上述错误,重映射仅部分应用。请再次运行脚本。

Yeah I don’t think we have conflict handling built in and you have incoming links for both domains.

You are going to need to manually delete stuff from the problem table prior to running this task.

3 个赞

Thanks Sam for the fast reply!

Could you please point me to where I can manipulate the problematic table?

rails c
DB.exec "update from incoming_domains set name='discourse-old.coretabs.net' where name = 'discourse.coretabs.net'"

Is likely what you want it will lead to a minor data inconsistency but at least the remap will probably work.

2 个赞

So here is what I did:

  1. I run the command you pointed out (without from :grin:)

  2. Run the rebake again, now it stopped here:

Rewriting all occurences of forums.coretabs.net to discourse.coretabs.net
THIS TASK WILL REWRITE DATA, ARE YOU SURE (type YES)
YES
incoming_domains=1
incoming_referers=3
invites=1
javascript_caches=1
post_revisions=509
posts=84
single_sign_on_records=1099
theme_fields=4
topic_custom_fields=4
Error: ERROR:  duplicate key value violates unique constraint "unique_post_links"
DETAIL:  Key (topic_id, post_id, url)=(69, 212, https://discourse.coretabs.net/t/topic/365) already exists.
The remap has only been partially applied due to the error above. Please re-run the script again.
  1. Googled "unique_post_links" and found that its table is called topic_links from the schema.sql

  2. This time links are partial so I used a replace query:

DB.exec "update topic_links set url=REPLACE(url, 'discourse.coretabs.net', 'discourse-old.coretabs.net')"
  1. Run the rebake again.

Works like a charm, thanks Sam :rose:

5 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.