Commit dd45a174 authored by Sean McGivern's avatar Sean McGivern

Improve down step of removing issues.assignee_id column

Using update_column_in_batches means that we can chunk the updates.
parent 43442be4
......@@ -25,6 +25,12 @@ class RemoveAssigneeIdFromIssue < ActiveRecord::Migration
# comments:
disable_ddl_transaction!
class Issue < ActiveRecord::Base
self.table_name = 'issues'
include ::EachBatch
end
def up
remove_column :issues, :assignee_id
end
......@@ -33,6 +39,8 @@ class RemoveAssigneeIdFromIssue < ActiveRecord::Migration
add_column :issues, :assignee_id, :integer
add_concurrent_index :issues, :assignee_id
execute('UPDATE issues SET assignee_id = (SELECT user_id FROM issue_assignees WHERE issue_assignees.issue_id = issues.id LIMIT 1)')
update_value = Arel.sql('(SELECT user_id FROM issue_assignees WHERE issue_assignees.issue_id = issues.id LIMIT 1)')
update_column_in_batches(:issues, :assignee_id, update_value)
end
end
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