From 4d29b679395a233540ea5c7c218dd91ad3a795ab Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 4 May 2020 16:29:39 -0500 Subject: [PATCH] Use common set of tables and columns to migrate on upgrade for rename_uploader_column migration --- .../migrate/rename_uploader_columns.rb | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/migrate/rename_uploader_columns.rb b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/migrate/rename_uploader_columns.rb index 0829487c..672aa8e1 100644 --- a/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/migrate/rename_uploader_columns.rb +++ b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/migrate/rename_uploader_columns.rb @@ -1,19 +1,9 @@ # License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later class RenameUploaderColumns < ActiveRecord::Migration[5.2] - rename_column :campaigns, :main_image, :main_image_temp - rename_column :campaigns, :background_image, :background_image_temp - rename_column :campaigns, :banner_image, :banner_image_temp - - rename_column :events, :main_image, :main_image_temp - rename_column :events, :background_image, :background_image_temp - - rename_column :image_attachments, :file, :file_temp - - rename_column :nonprofits, :main_image, :main_image_temp - rename_column :nonprofits, :second_image, :second_image_temp - rename_column :nonprofits, :third_image, :third_image_temp - rename_column :nonprofits, :background_image, :background_image_temp - rename_column :nonprofits, :logo, :logo_temp - - rename_column :profiles, :picture, :picture_temp + require "houdini_upgrade" + HoudiniUpgrade::UPLOADERS_TO_MIGRATE.each do |table| + table.fields.each do |field| + rename_column table.name, field.name, field.migrated_name + end + end end \ No newline at end of file