迁移优化,原来需要1800秒,现只需800秒
This commit is contained in:
parent
0402fee6de
commit
c893a2d99b
|
@ -1,9 +1,11 @@
|
|||
class AddDataToProjectIssuesIndexsInIssue < ActiveRecord::Migration
|
||||
def change
|
||||
for i in 1 ... 1000 do i
|
||||
Issue.page(i).per(10).each do |e|
|
||||
index = e.project.issues.index(e).to_i + 1
|
||||
execute("update issues set project_issues_index = #{index} where id = #{e.id}")
|
||||
transaction do
|
||||
for i in 1 ... 1000 do i
|
||||
Issue.page(i).per(10).each do |e|
|
||||
index = e.project.issues.index(e).to_i + 1
|
||||
execute("update issues set project_issues_index = #{index} where id = #{e.id}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue