The blog has moved to http://jessehouse.com/ ... Many google searches point here so I am leaving it operational, but there will be no new posts.

Saturday, May 9, 2009

PGError: ERROR: duplicate key value violates unique constraint "tablename_pkey"

Using Postgresql I ran into the following error when trying to create a new record through my rails application

  • PGError: ERROR: duplicate key value violates unique constraint "tablename_pkey"

Found this link which had the needed fix;

Dealing with 'duplicate key violates unique constraint' on the primary key

apparently with Postgresql after bulk loading records where the auto incrementing id is specified you then need to update the sequence value

No comments: