Skip to content

Instantly share code, notes, and snippets.

@joshsusser
Created March 1, 2011 23:13
Show Gist options
  • Save joshsusser/850100 to your computer and use it in GitHub Desktop.
Save joshsusser/850100 to your computer and use it in GitHub Desktop.
reset all db tables before re-seeding
# reset tables
tables = ActiveRecord::Base.connection.tables
tables.delete("schema_migrations")
tables.each do |table|
ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{table}")
ActiveRecord::Base.connection.reset_pk_sequence!(table)
end
# seed data
#
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment