wac*_*nia 13 migration postgresql ruby-on-rails ruby-on-rails-6
将应用程序 Rails 5.2 更新为 6,更新添加了以下两个迁移:
# 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
end
Run Code Online (Sandbox Code Playgroud)
和
# This migration comes from active_storage (originally 20191206030411)
class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0]
def up
create_table :active_storage_variant_records do |t|
t.belongs_to :blob, null: false, index: false
t.string :variation_digest, null: false
t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true
t.foreign_key :active_storage_blobs, column: :blob_id
end
end
end
Run Code Online (Sandbox Code Playgroud)
尝试运行迁移会在标题上出现错误。网上没找到,有什么解决办法吗?
Adi*_*dim 31
该active_storage_blobs
表尚不存在。您需要先运行:
rails active_storage:install
Run Code Online (Sandbox Code Playgroud)
此命令将为 2 个表添加 2 个迁移:active_storage_attachments
和active_storage_blobs
.
这些新的迁移需要在您上面的迁移之前运行。对此有一个技巧,您可以考虑手动将上述 2 个迁移的文件名中的时间戳更改为高于 2 个新迁移active_storage:install
将创建的时间戳。
一旦所有这些都被排序,运行 rake db:migrate
归档时间: |
|
查看次数: |
2957 次 |
最近记录: |