Error running remap after changing site url

I changed the URL of my discourse site, and am following the directions in Change the domain name or rename your Discourse. When attempting to run remap, I am repeatedly getting the following error. It keeps telling me to re-run the script but then the same error occurs each time.[1]

I’m not sure what my next move is here and would be grateful for guidance. Thanks in advance! :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. I know the definition of insanity is to repeat the same thing over and over again and to expect a different result! :rofl: ↩︎

looks like a constraint collision in the postgres analytics table. your database already includes records of the new domain on specific dates so the remap tool is likely creating duplicates and postgres is rejecting them.

i would try to delete the old domain records in the specific table only for the dates where the new domain already has data in order to preserve historical data and unblock the remap tool. do a safety backup first though.

try this:

cd /var/discourse
./launcher enter app
# create a safety backup
discourse backup
# enter the database console
discourse db
/* find the exact table name tied to this index */
SELECT tablename 
FROM pg_indexes 
WHERE indexname = 'idx_bprd_rollups_date_referrer_unique';

assuming the query above returns browser_pageview_rollup_details then use that table name in the next query

/* delete the colliding analytics records */
DELETE FROM browser_pageview_rollup_details 
WHERE normalized_referrer = 'discourse.tobiaseigen.org' 
AND date IN (
    SELECT date 
    FROM browser_pageview_rollup_details 
    WHERE normalized_referrer = 'digitallysovereign.org'
);

/* exit postgres */
\q

then run the remap tool again

discourse remap discourse.tobiaseigen.org digitallysovereign.org

then use rebake_match rake task instead of full rebake

# rebake only posts containing the new domain string
rake posts:rebake_match["digitallysovereign.org"]