From ead3f67e88af80cdb8d14e095b7ded2965f021c9 Mon Sep 17 00:00:00 2001 From: piecehealth Date: Thu, 10 Feb 2022 18:01:09 +0800 Subject: [PATCH] fix activestorage update --- ...20190112182829_add_service_name_to_active_storage_blobs.rb | 4 ++++ .../20191206030411_create_active_storage_variant_records.rb | 2 ++ ...233751_remove_not_null_on_active_storage_blobs_checksum.rb | 2 ++ 3 files changed, 8 insertions(+) diff --git a/activestorage/db/update_migrate/20190112182829_add_service_name_to_active_storage_blobs.rb b/activestorage/db/update_migrate/20190112182829_add_service_name_to_active_storage_blobs.rb index 9775303e27..6076d58bac 100644 --- a/activestorage/db/update_migrate/20190112182829_add_service_name_to_active_storage_blobs.rb +++ b/activestorage/db/update_migrate/20190112182829_add_service_name_to_active_storage_blobs.rb @@ -1,5 +1,7 @@ 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 @@ -12,6 +14,8 @@ class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0] end def down + return unless table_exists?(:active_storage_blobs) + remove_column :active_storage_blobs, :service_name end end diff --git a/activestorage/db/update_migrate/20191206030411_create_active_storage_variant_records.rb b/activestorage/db/update_migrate/20191206030411_create_active_storage_variant_records.rb index 6bb2a6bb15..0ff7345c6b 100644 --- a/activestorage/db/update_migrate/20191206030411_create_active_storage_variant_records.rb +++ b/activestorage/db/update_migrate/20191206030411_create_active_storage_variant_records.rb @@ -1,5 +1,7 @@ class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0] def change + return unless table_exists?(:active_storage_blobs) + # Use Active Record's configured type for primary key create_table :active_storage_variant_records, id: primary_key_type, if_not_exists: true do |t| t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type diff --git a/activestorage/db/update_migrate/20211119233751_remove_not_null_on_active_storage_blobs_checksum.rb b/activestorage/db/update_migrate/20211119233751_remove_not_null_on_active_storage_blobs_checksum.rb index 60b4aaa706..d00315e7e5 100644 --- a/activestorage/db/update_migrate/20211119233751_remove_not_null_on_active_storage_blobs_checksum.rb +++ b/activestorage/db/update_migrate/20211119233751_remove_not_null_on_active_storage_blobs_checksum.rb @@ -1,5 +1,7 @@ class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0] def change + return unless table_exists?(:active_storage_blobs) + change_column_null(:active_storage_blobs, :checksum, true) end end