The Wed, 14 Apr 2010 12:09:57 -0700 (PDT),
Rick <[email protected]> wrote:

> [...]
> ActiveRecord::StatementInvalid: PGError: ERROR:  duplicate key value
> violates unique constraint "numbers_pkey"
> : INSERT INTO "numbers" ("name", "created_at", "updated_at", "value")
> VALUES(E'nine', '2010-04-14 19:07:44.694130', '2010-04-14
> 19:07:44.694130', 8) RETURNING "id"
> 
> 
> Any ideas?
> 

You used COPY to insert data without adjusting the sequence used to
initialize the id column value.

As ActiveRecord relies on the DB to fill the id column for you, the DB
calls nextval() on the sequence, gets 1 which is already used.

See 
psql> \d numbers 
for the name of the sequence used for the id column and lookup
PostgreSQL doc for how to change the value it stores (sorry I don't
remember the exact SQL syntax).

Lionel

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to