-
-
Save alfie-max/0788b9b363b196df4ee3b5b79a89382e to your computer and use it in GitHub Desktop.
Rails list all tables count
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tables = [] | |
ActiveRecord::Base.connection.tables.each do |t| | |
count = ActiveRecord::Base.connection.exec_query("select count(*) from #{t}").rows[0][0] | |
tables << [t, count.to_i] | |
end | |
tables.sort_by { |t| t[1] }.reverse! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment