# Move posts 500 error due to constraint

**URL:** https://meta.discourse.org/t/move-posts-500-error-due-to-constraint/129198
**Category:** Bug
**Created:** [21 september 2019 om 14:58 UTC](https://meta.discourse.org/t/move-posts-500-error-due-to-constraint/129198 "2019-09-21T14:58:08Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![nmcgovern](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nmcgovern/32/132630_2.png) [@nmcgovern](https://meta.discourse.org/u/nmcgovern)
#### Post date: [21 september 2019 om 14:58 UTC](https://meta.discourse.org/t/move-posts-500-error-due-to-constraint/129198/1 "2019-09-21T14:58:09Z")

</div>

Hi,

A topic started to drift, so I split it to a new topic. Unfortunately, it’s now going back on topic, so I tried to move the relevant posts back to the original one. I’m getting a 500 error.

It seems a constraint is failing:

```plaintext
2019-09-21 14:39:48.805 UTC [26689] discourse@discourse ERROR: duplicate key value violates unique constraint "post_timings_unique"`
`2019-09-21 14:39:48.805 UTC [26689] discourse@discourse DETAIL: Key (topic_id, post_number, user_id)=(9957, 79, 1) already exists.`
`2019-09-21 14:39:48.805 UTC [26689] discourse@discourse STATEMENT: UPDATE post_timings pt
        SET topic_id = mp.new_topic_id,
            post_number = mp.new_post_number
        FROM moved_posts mp
        WHERE pt.topic_id = mp.old_topic_id
          AND pt.post_number = mp.old_post_number
          AND mp.old_post_id = mp.new_post_id`
        
`2019-09-21 14:39:48.806 UTC [26689] discourse@discourse ERROR: current transaction is aborted, commands ignored until end of transaction block`
`2019-09-21 14:39:48.806 UTC [26689] discourse@discourse STATEMENT: DROP TABLE IF EXISTS moved_posts

```

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [10 januari 2020 om 06:39 UTC](https://meta.discourse.org/t/move-posts-500-error-due-to-constraint/129198/2 "2020-01-10T06:39:32Z")

</div>

Is there a clear repro here, can you make it happen on a new topic?

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [10 januari 2020 om 16:03 UTC](https://meta.discourse.org/t/move-posts-500-error-due-to-constraint/129198/3 "2020-01-10T16:03:07Z")

</div>

I’m pretty sure this was fixed by [FIX: Existing post timings could prevent moving posts · discourse/discourse@bee000b · GitHub](https://github.com/discourse/discourse/commit/bee000bcec250dc7778a922a4af577e119863f6f).  
@nmcgovern Please flag to reopen if you are still able to reproduce the issue.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [10 januari 2020 om 16:03 UTC](https://meta.discourse.org/t/move-posts-500-error-due-to-constraint/129198/4 "2020-01-10T16:03:12Z")

</div>


