Skip to content

Commit

Permalink
rollback migrattion of add service name
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoparma88 committed Sep 29, 2023
1 parent 115b218 commit 72fcfff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0]
def up
return if column_exists?(:active_storage_blobs, :service_name)

add_column :active_storage_blobs, :service_name, :string, null: false, default: ''
add_column :active_storage_blobs, :service_name, :string

return unless (configured_service = ActiveStorage::Blob.service.name)
if (configured_service = ActiveStorage::Blob.service.name)
ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) # rubocop:disable Rails/SkipsModelValidations
end

ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) # rubocop:disable Rails/SkipsModelValidations
change_column :active_storage_blobs, :service_name, :string, null: false
end

def down
remove_column :active_storage_blobs, :service_name
end
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
t.bigint "byte_size", null: false
t.string "checksum"
t.datetime "created_at", precision: nil, null: false
t.string "service_name", default: "", null: false
t.string "service_name", null: false
t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
end

Expand Down

0 comments on commit 72fcfff

Please sign in to comment.