Skip to content

Instantly share code, notes, and snippets.

@aliang
Created October 26, 2015 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aliang/593f52e89ed86a2b4449 to your computer and use it in GitHub Desktop.
Save aliang/593f52e89ed86a2b4449 to your computer and use it in GitHub Desktop.
models = ActiveRecord::Base.descendants
models.each do |m|
last_id = m.last.id
m.connection.execute("ALTER SEQUENCE #{m.table_name}_id_seq RESTART WITH #{last_id}")";
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment