我有一个 Rails 迁移文件,要向一个非常大的表添加索引,并意识到引入一项会锁定该表且可能会阻塞 Semaphore 构建处理的迁移操作风险很大。因此,我选择了安全的方式,触发了并发索引构建。
class AddIndexToEventsTable < ActiveRecord::Migration[5.2]
disable_ddl_transaction!
def change
add_index :events, [:status, :created_at], algorithm: :concurrently
end
end
但是迁移后,发现不成功,在这里出现了错误:
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
Algorithm must be one of the following: :default, :copy, :inplace
我正在使用 rails 5.2.5
我该如何在MYSQL上实现类似于algorithm: :concurrently
在PostGres中的功能。
:concurrently
更改为:default
。 - Rick James