Mind Dump, Tech And Life Blog
written by Ivan Alenko
published under license Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)copy! share!
posted at 24. Aug '21

Howto Fix Broken Autoincrement - Postgres PG::UniqueViolation - Duplicate Key


ActiveRecord::RecordNotUnique (PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "articles_pkey")
DETAIL:  Key (id)=(101) already exists.

Go to Rails console and type:


Where the parameter is more less the name of the index (on field).

Add Comment