akkounts/db/migrate/20250428123315_add_service_name_to_active_storage_blobs.active_storage.rb
Râu Cao 1ddecab2c3
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Upgrade Rails to 8.0
2025-04-28 17:49:54 +04:00

23 lines
718 B
Ruby

# This migration comes from active_storage (originally 20190112182829)
class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0]
def up
return unless table_exists?(:active_storage_blobs)
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
end
end
def down
return unless table_exists?(:active_storage_blobs)
remove_column :active_storage_blobs, :service_name
end
end