[ipboard.rb] ERROR: duplicate key value violates unique constraint "import_ids_pkey" (PG::UniqueViolation)

סיכום מבוסס בינה מלאכותית

In a migration discussion titled “[ipboard.rb] ERROR: duplicate key value violates unique constraint ‘import_ids_pkey’”, t-e-d-d-y reported encountering a PostgreSQL unique constraint error while importing topics from IPB 3.4 using the ipboard.rb script, specifically for topic ID 2264 and several others. After deleting the problematic topics from the database, the import succeeded but resulted in data loss. pfaffman speculated that the script might be using incorrect IDs or misinterpreting the source data, and questioned whether the topics were deleted mid-import. t-e-d-d-y confirmed the issue persisted across fresh database installs and multiple environments, with no underlying IPB database corruption. pfaffman suggested manually inspecting the topic-fetching query to check for duplicate results. t-e-d-d-y asked if the fix should be applied directly in the ipboard.rb script, to which pfaffman advised running the query manually to debug. Ultimately, t-e-d-d-y resolved the issue by discovering that several posts linked to the problematic topics had the new_topic = 1 flag set incorrectly — manually resetting these fields allowed the import to complete successfully. The root cause remains unexplained, but the workaround restored full data integrity.

Hello, i’m trying to import an IPB 3.4 forum using ipboard.rb, i got this error with topic import :

.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rack-mini-profiler-2.3.3/lib/patches/db/pg.rb:56:in `exec': ERROR:  duplicate key value violates unique constraint "import_ids_pkey" (PG::UniqueViolation)
DETAIL:  Key (val)=(discussion#2264) already exists.

I deleted the 2264 topic from sql database and launch the script again, now its ok… but i lost the topic :sob: and 5 or 6 other important topics with the same error. What’s wrong ? How can i import these topics ?

Thanks.

Maybe the script is using the wrong ID? Or maybe the version you’re coming from isn’t what the script expects.

You didn’t run the script, then delete topics and try to run it again did you?

I got this issue only with 9 topics, every else is ok, and i allways start from fresh install database, checked with differents sql backups and differents hosts. No error found in ipboard (index, database etc.).
I dont understand. :confused:

Souds like something non-obvious. My best guess is something like. . . well. I don’t have a best guess.

Maybe the query is somehow returning those topics twice somehow? You might try adding a .where ID=123 to the query that’s getting the topics to see if it’s somehow getting it twice and then figure out why.

Should i add it to ipboard.rb file ?

I world look at the query in the script and do it by hand as I described and see what the results are

Ok, I found ! :sunglasses:
Thank you for directing me to the solution. Look, I don’t know why but several posts related to problematic topics had the field new_topic = 1.

Note: I manually edited the fields and everything is ok now.