aboutsummaryrefslogtreecommitdiff
path: root/db/migrate/20210121192038_add_service_name_to_active_storage_blobs.active_storage.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20210121192038_add_service_name_to_active_storage_blobs.active_storage.rb')
-rw-r--r--db/migrate/20210121192038_add_service_name_to_active_storage_blobs.active_storage.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/db/migrate/20210121192038_add_service_name_to_active_storage_blobs.active_storage.rb b/db/migrate/20210121192038_add_service_name_to_active_storage_blobs.active_storage.rb
new file mode 100644
index 0000000..9967a13
--- /dev/null
+++ b/db/migrate/20210121192038_add_service_name_to_active_storage_blobs.active_storage.rb
@@ -0,0 +1,18 @@
+# This migration comes from active_storage (originally 20190112182829)
+class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0]
+ def up
+ 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
+ remove_column :active_storage_blobs, :service_name
+ end
+end