# Невозможно переместить сообщения между темами

**URL:** https://meta.discourse.org/t/unable-to-move-posts-between-topics/341497
**Category:** Bug
**Tags:** fixed
**Created:** [10.Декабрь.2024 02:24:05 UTC](https://meta.discourse.org/t/unable-to-move-posts-between-topics/341497 "2024-12-10T02:24:05Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![nat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nat/32/235063_2.png) [@nat](https://meta.discourse.org/u/nat)
#### Post date: [10.Декабрь.2024 09:30:07 UTC](https://meta.discourse.org/t/unable-to-move-posts-between-topics/341497/2 "2024-12-10T09:30:07Z")

</div>

Отличные новости, мы только что объединили исправление:

> <https://github.com/discourse/discourse/pull/30176>
>
> \## ✨ What's This?
> 
> When moving posts to an existing topic whilst preserving ch…ronological ordering, the second chunk of posts moved can trigger a PostgreSQL error:
> 
> \`\`\`
> PG::UniqueViolation (ERROR: duplicate key value violates unique constraint "post\_timings\_unique"
> DETAIL: Key (topic\_id, post\_number, user\_id)=(36, 29, 1) already exists.
> )
> lib/mini\_sql\_multisite\_connection.rb:109:in \`run'
> app/models/post\_mover.rb:432:in \`copy\_shifted\_post\_timings\_from\_temp'
> app/models/post\_mover.rb:118:in \`handle\_moved\_references'
> app/models/post\_mover.rb:94:in \`move\_posts\_to'
> app/models/post\_mover.rb:28:in \`block in to\_topic'
> app/models/post\_mover.rb:28:in \`to\_topic'
> \`\`\`
> 
> The cause of this error is a little bit silly.
> 
> After a post has been moved from a different topic, a moderator post is inserted into the old topic, pointing to where the post has been moved to.
> 
> This moderator post is ultimately created using \`PostCreator\`, which by default, records a 5000ms Post Timing for that newly created post. Because of how Post Timings are tracked, this timing will be inserted into the \`post\_timings\` table with the same \`topic\_id\`, \`post\_number\`, and \`user\_id\` as the moved post used to have before it was moved.
> 
> Now, when we proceed to moving the next post, \`PostMover.move\_post\_timings\` will look for post timings to move based on whether there's a corresponding entry in the \`moved\_posts\` table. This is where our problem lays: the post that we previously moved has an entry in the \`moved\_posts\` table, but now there's an unexpected entry in \`post\_timings\` that we know doesn't belong to the previously moved post, but it has matching \`topic\_id\`, \`post\_number\`, and \`user\_id\` of the what that moved post used to have, anyway.
> 
> To fix this, we can enforce only matching post IDs that are being moved in this run of \`PostMover\`.
> 
> Internal ref t/142010/5
> 
> \## 👑 Testing
> 
> The simplest way to reproduce this error is:
> 
> \- Create a destination topic.
> \- Create the first source topic, and add a reply to it.
> \- Create a second source topic, and add a reply to it.
> \- Move the reply in the second source topic to the destination topic, remembering to check the “preserve chronological order” option.
> \- Move the reply in the first source topic to the destination, again checking the “preserve chronological order” option.

Не уверен, сможете ли вы прямо сейчас обновить свой сайт, но это должно помочь преодолеть эту ошибку.

---

_[View the full topic](https://meta.discourse.org/t/unable-to-move-posts-between-topics/341497)._
