Last active
March 30, 2023 16:35
-
-
Save caioagiani/88d50616627f4ba5110580d3a285e6e1 to your computer and use it in GitHub Desktop.
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_and_columns = [] | |
ActiveRecord::Base.connection.tables.count | |
ActiveRecord::Base.connection.tables.each do |table_name| | |
count = ActiveRecord::Base.connection.columns(table_name).count | |
tables_and_columns << { table_name: table_name, column_count: count } | |
end | |
tables_and_columns.sort_by! { |tc| tc[:table_name] } | |
tables_and_columns.each { |tc| puts "#{tc[:table_name]}, #{tc[:column_count]}" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment