Fix slow fallback of CopyAccountStats migration setting stats to 0 (#9930)

This commit is contained in:
Eugen Rochko 2019-01-28 04:18:35 +01:00 提交者 GitHub
父節點 d4300c3b98
當前提交 5d312ef9c7
沒有發現已知的金鑰在資料庫的簽署中
GPG 金鑰 ID: 4AEE18F83AFDEB23
共有 1 個檔案被更改,包括 1 行新增1 行删除

查看文件

@ -44,7 +44,7 @@ class CopyAccountStats < ActiveRecord::Migration[5.2]
# uniqueness violations that we need to skip over
Account.unscoped.select('id, statuses_count, following_count, followers_count, created_at, updated_at').find_each do |account|
begin
params = [[nil, account.id], [nil, account.statuses_count], [nil, account.following_count], [nil, account.followers_count], [nil, account.created_at], [nil, account.updated_at]]
params = [[nil, account.id], [nil, account[:statuses_count]], [nil, account[:following_count]], [nil, account[:followers_count]], [nil, account.created_at], [nil, account.updated_at]]
exec_insert('INSERT INTO account_stats (account_id, statuses_count, following_count, followers_count, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6)', nil, params)
rescue ActiveRecord::RecordNotUnique
next