Bob Gustafson wrote in post #1092090:
> Lance wrote in post #93083:
>> There is a method in the Postgresql adapter called reset_pk_sequence.  I
>> haven't used it yet but it sounds like this is what you are looking for.
>
> I used it:
>
> Account.delete_all
> Account.reset_pk_sequence
>
> but, it didn't work. The next Account.save had the :id = last :id + 1
>
> At least it didn't crash :-)
>
> I'm still looking for a solution.

Here is the solution:

Account.delete_all
Account.connection.execute "ALTER SEQUENCE accounts_id_seq RESTART WITH
1"

Hope this helps

Bob G

-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to