QutEcoacoustics / baw-server

The acoustic workbench server for storing and managing ecoacoustic data. Manages the structure and audio data. Provides an API for clients access.
Apache License 2.0
9 stars 4 forks source link

Reset postgres id sequence on duplicate id error #468

Open Allcharles opened 4 years ago

Allcharles commented 4 years ago

Depending on how data is imported into the postgres database, the id sequence may not be updated to reflect the newest id which should be inserted. This can cause any attempts to create a new model to return an error as the id is not unique. To fix this, the error should be detected, and the sequence reset for the table.

Relevant link: http://www.osny.me/blog/how-to-reset-postgres-id-sequence-in-a-ruby-on-rails-app