BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
dd45a174
Commit
dd45a174
authored
Dec 11, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve down step of removing issues.assignee_id column
Using update_column_in_batches means that we can chunk the updates.
parent
43442be4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
20170523073948_remove_assignee_id_from_issue.rb
db/migrate/20170523073948_remove_assignee_id_from_issue.rb
+9
-1
No files found.
db/migrate/20170523073948_remove_assignee_id_from_issue.rb
View file @
dd45a174
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment