Skip to content

Instantly share code, notes, and snippets.

@AndreiRailean
Created January 22, 2015 02:49
Show Gist options
  • Save AndreiRailean/d2134dc38258f2d6e3bb to your computer and use it in GitHub Desktop.
Save AndreiRailean/d2134dc38258f2d6e3bb to your computer and use it in GitHub Desktop.
Fix Rails Sequences
# Run this when your sequences get out of whack
# Can happen after a botched database restore
# Tested with postgres
ActiveRecord::Base.connection.tables.each do |table|
ActiveRecord::Base.connection.reset_pk_sequence!(table)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment