I have a company table and I want to check the existence of multiple column to remove them.
class RemoveSettingsReportColumnsFromCompany < ActiveRecord::Migration[5.1]
def change
if column_exists?( :companies, :automatically_send_report ) && column_exists?( :companies, :time_limit_for_sending_report ) && column_exists?( :companies, :report_fragment_color ) && column_exists?( :companies, :display_default_avatar )
remove_column :companies, :automatically_send_report, :boolean
remove_column :companies, :time_limit_for_sending_report, :integer
remove_column :companies, :report_fragment_color, :string
remove_column :companies, :display_default_avatar, :boolean
end
end
end
As you see there is a redundancy of use of the function column_exists, and I want to better organize and reduce my code, can some one tell if there is a way to use column_exists in other way, and give it as parameters all columns I want to remove ?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)