# Update failed due to primary key sequence error

**URL:** <https://meta.discourse.org/t/update-failed-due-to-primary-key-sequence-error/67852>\
**Category:** Self-hosting\
**Created:** [2017 年 8 月 11 日午前 5:51 UTC](https://meta.discourse.org/t/update-failed-due-to-primary-key-sequence-error/67852 "2017-08-11T05:51:42Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)\
**Post date:** [2017 年 8 月 11 日午前 7:27 UTC](https://meta.discourse.org/t/update-failed-due-to-primary-key-sequence-error/67852/6 "2017-08-11T07:27:49Z")

</div>

Oh… kay. That’s not entirely what I was expecting. In a perfect world, I’d love to know how you’ve managed to end up with a sequence so far out of whack, but I’m guessing we’re not going to live in a perfect world today.

The easy solution is run the following in `psql`:

```
alter sequence schema_migration_details_id_seq restart 750;

```

That’ll get the sequence back on track, and will stop the error from occuring. _However_, without knowing how this happened (I’ve _never_ seen it happen before, and I’ve been doing this a long time), I can’t guarantee there might not be other craziness lurking in your database. You may well be in for a rough time.

---

_[View the full topic](https://meta.discourse.org/t/update-failed-due-to-primary-key-sequence-error/67852)._
