Commit b84723ac authored by Valery Sizov's avatar Valery Sizov

[Issue Sorting] Improve migration

parent 56707777
...@@ -7,10 +7,9 @@ class ResetRelativePositionForIssue < ActiveRecord::Migration ...@@ -7,10 +7,9 @@ class ResetRelativePositionForIssue < ActiveRecord::Migration
DOWNTIME = false DOWNTIME = false
def up def up
execute <<-EOS update_column_in_batches(:issues, :relative_position, nil) do |table, query|
UPDATE issues SET relative_position = NULL query.where(table[:relative_position].not_eq(nil))
WHERE issues.relative_position IS NOT NULL; end
EOS
end end
def down def down
......
...@@ -130,7 +130,6 @@ describe Issue, 'RelativePositioning' do ...@@ -130,7 +130,6 @@ describe Issue, 'RelativePositioning' do
expect(new_issue.relative_position).to eq(6000 + RelativePositioning::DISTANCE) expect(new_issue.relative_position).to eq(6000 + RelativePositioning::DISTANCE)
end end
it 'positions issue in the middle of other two if distance is not big enough' do it 'positions issue in the middle of other two if distance is not big enough' do
issue.update relative_position: 100 issue.update relative_position: 100
issue1.update relative_position: 400 issue1.update relative_position: 400
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment