read

When doing multiple imports and deletions of development data I got into a state where I couldn’t insert into ActiveRecord because the id was already taken.

To fix that I used the following code to reset the pk_sequence on all of my tables.

ActiveRecord::Base.connection.tables.each do |t|
  ActiveRecord::Base.connection.reset_pk_sequence!(t)
end
Blog Logo

Ben Wyrosdick


Published

Image

Ben Wyrosdick

Personal & Techical Blog

Back to Overview