Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mecampbellsoup/eb398e8ab158a74b1ff9a64f021ce79a to your computer and use it in GitHub Desktop.

Select an option

Save mecampbellsoup/eb398e8ab158a74b1ff9a64f021ce79a to your computer and use it in GitHub Desktop.
# to be run from within a sandbox and production rails console instance
table_names = %w(
ach_file_transitions
ach_file_deliveries
ach_file_archives
ach_files
delivery_targets
batches
entries
token_credentials
webhooks
)
# count the total # of records in each of the tables in table_names
table_names.each do |name|
puts "===================="
puts "===================="
puts "===================="
puts "Counting records for table: #{name}..."
sql = "select count(*) from public.#{name}"
conn = ActiveRecord::Base.connection
count = conn.execute(sql).values[0][0]
puts "There are: #{count} total records in the #{name} table."
puts "===================="
puts "===================="
puts "===================="
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment