2

I'm doing a Rails 6.1 upgrade at the moment and wondering if there's a way to set the new service_name column to be ignored. I know how to do this with an ActiveRecord table, but not a Rails' internal table (not sure what to call it).

So above details aside, how does one set a column in the active_storage_blobs table to be ignored?

2
  • You would do it by monkeypatching the ActiveStorage::Blob class, but why do you think its necissary in the first place? Commented Nov 5, 2021 at 14:10
  • 1
    yeah, I'd rather not for sure, but, I operate in a busy application that doesn't want to experience down time to do this upgrade. The changes required for ActiveStorage Blobs in 6.1 are a bit of lock step issue. In 6.1 ActiveStorage Blob requires service_name. Ideally I'd be able to backport the change (i.e., run the migration in 6.0), and then I don't have to lock the database/have downtime for the period of the upgrade and migration. However in 6.0 doing this migration doesn't work unless I can ignore the column. Could monkeypatch, I'll look into it. Was hoping for an easy "Rails way" Commented Nov 5, 2021 at 14:40

1 Answer 1

1
# app/initializers/active_storage_ignore_service_name_backport.rb

module ActiveStorageIgnoreServiceNameBackport
  extend ActiveSupport::Concern

  included do
    ignored_columns = [:service_name]
  end
end

Rails.configuration.to_prepare do
  ActiveStorage::Blob.include(ActiveStorageIgnoreServiceNameBackport)
end
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.