gpt4 book ai didi

ruby-on-rails - PG::UndefinedTable: 错误: 关系 "active_storage_blobs"不存在

转载 作者:行者123 更新时间:2023-12-03 16:40:06 28 4
gpt4 key购买 nike

将应用程序 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


# 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

尝试运行迁移会在标题上出现错误。网上没找到,有什么解决办法吗?

最佳答案

active_storage_blobs表尚不存在。您需要先运行:

rails active_storage:install

此命令将为 2 个表添加 2 个迁移: active_storage_attachmentsactive_storage_blobs .

这些新的迁移需要在您上面的迁移之前运行。对此有一个技巧,您可以考虑手动将上述 2 个迁移文件名中的时间戳更改为高于 2 个新迁移的时间戳 active_storage:install将创建。

一旦所有这些都被排序,运行 rake db:migrate

关于ruby-on-rails - PG::UndefinedTable: 错误: 关系 "active_storage_blobs"不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59857774/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com