From 7ea89ecac63fcf94dacf90d58a38a4ee9659df46 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 14 Sep 2021 20:12:12 -0700 Subject: [PATCH] actually, lets just tackle it this way --- ..._remove_service_name_from_active_storage_blobs.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/db/migrate/20210915030031_remove_service_name_from_active_storage_blobs.rb b/db/migrate/20210915030031_remove_service_name_from_active_storage_blobs.rb index 935d09bc..53f6dbdf 100644 --- a/db/migrate/20210915030031_remove_service_name_from_active_storage_blobs.rb +++ b/db/migrate/20210915030031_remove_service_name_from_active_storage_blobs.rb @@ -1,19 +1,13 @@ class RemoveServiceNameFromActiveStorageBlobs < ActiveRecord::Migration[6.0] def up if column_exists?(:active_storage_blobs, :service_name) - remove_column :active_storage_blobs, :service_name + change_column_default :active_storage_blobs, :service_name, "amazon" end end def down - unless column_exists?(:active_storage_blobs, :service_name) - add_column :active_storage_blobs, :service_name, :string - - if configured_service = ActiveStorage::Blob.service.name - ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) - end - - change_column :active_storage_blobs, :service_name, :string, null: false + if column_exists?(:active_storage_blobs, :service_name) + change_column_default :active_storage_blobs, :service_name, nil end end end