Last active
July 29, 2023 17:15
-
-
Save sshaw/1d860c13d9b22c8e27a954e109072ad6 to your computer and use it in GitHub Desktop.
Rails: Print What Models Have Ignored Columns That No Longer Exist in DB (Moved: https://github.com/sshaw/ignored_columns_tasks)
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
(ApplicationRecord.subclasses + ActiveRecord::Base.subclasses).each do |klass| | |
next if klass.abstract_class? || klass.ignored_columns.none? | |
ignored = klass.ignored_columns | |
klass.ignored_columns = [] | |
klass.reset_column_information | |
removed = ignored - klass.column_names | |
klass.ignored_columns = ignored | |
next unless removed.any? | |
printf "%s: %s\n", klass.name, removed.to_sentence | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
rails r print-non-existant-ignored-columns.rb