サイトURLを変更した後のremap実行エラー

DiscourseサイトのURLを変更し、Change the domain name or rename your Discourse の手順に従って操作しています。remapを実行しようとしたところ、以下のエラーが繰り返し発生します。スクリプトを再実行するように促されますが、再実行しても同じエラーが毎回発生します。[1]

次に何をすればよいか分からず、アドバイスがあれば大変助かります。どうぞよろしくお願いいたします!:seedling:

root@digitallysovereign:/var/discourse# ./launcher enter app
x86_64 arch detected.
root@digitallysovereign-app:/var/www/discourse# discourse remap discourse.tobiaseigen.org digitallysovereign.org
Rewriting all occurrences of discourse.tobiaseigen.org to digitallysovereign.org
WILL RUN ON 'default' DB
THIS TASK WILL REWRITE DATA, ARE YOU SURE (type YES): YES

Remapping tables on default...

ai_api_audit_logs=919
ai_secrets=1
backup_metadata=1
browser_pageview_events=3664
Error: ERROR:  duplicate key value violates unique constraint "idx_bprd_rollups_date_referrer_unique"
DETAIL:  Key (date, normalized_referrer)=(2026-07-01, digitallysovereign.org) already exists.
The remap has only been partially applied due to the error above. Please re-run the script again.
root@digitallysovereign-app:/var/www/discourse# discourse remap discourse.tobiaseigen.org digitallysovereign.org
Rewriting all occurrences of discourse.tobiaseigen.org to digitallysovereign.org
WILL RUN ON 'default' DB
THIS TASK WILL REWRITE DATA, ARE YOU SURE (type YES): YES

Remapping tables on default...

Error: ERROR:  duplicate key value violates unique constraint "idx_bprd_rollups_date_referrer_unique"
DETAIL:  Key (date, normalized_referrer)=(2026-07-01, digitallysovereign.org) already exists.
The remap has only been partially applied due to the error above. Please re-run the script again.
root@digitallysovereign-app:/var/www/discourse# discourse remap discourse.tobiaseigen.org digitallysovereign.org
Rewriting all occurrences of discourse.tobiaseigen.org to digitallysovereign.org
WILL RUN ON 'default' DB
THIS TASK WILL REWRITE DATA, ARE YOU SURE (type YES): YES

Remapping tables on default...

Error: ERROR:  duplicate key value violates unique constraint "idx_bprd_rollups_date_referrer_unique"
DETAIL:  Key (date, normalized_referrer)=(2026-07-01, digitallysovereign.org) already exists.
The remap has only been partially applied due to the error above. Please re-run the script again.

  1. 同じことを何度も繰り返して違う結果を期待するのが「狂気」の定義だということは承知しています!:rofl: ↩︎

Postgres の分析テーブルで制約の競合が発生しているようです。データベースには、新しいドメインの特定日付のレコードがすでに含まれているため、remap ツールは重複を作成しようとしており、Postgres はそれらを拒否しています。

新しいドメインがデータを持っている日付のみを対象に、古いドメインのレコードを特定のテーブルから削除し、履歴データを保持しながら remap ツールのブロックを解除することを試みます。ただし、事前に安全なバックアップを作成してください。

以下を試してください:

cd /var/discourse
./launcher enter app
# 安全なバックアップを作成
discourse backup
# データベースコンソールに入る
discourse db
/* 競合するレコードを削除 */
DELETE FROM bprd_rollups 
WHERE normalized_referrer = 'discourse.tobiaseigen.org' 
AND date IN (
    SELECT date 
    FROM bprd_rollups 
    WHERE normalized_referrer = 'digitallysovereign.org'
);

/* Postgres を終了 */
\q

次に、remap ツールを再度実行します

discourse remap discourse.tobiaseigen.org digitallysovereign.org

その後、完全なリベイクではなく rebake_match rake タスクを使用します

# 新しいドメイン文字列を含む投稿のみをリベイク
rake posts:rebake_match["digitallysovereign.org"]