Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b2186b67
Commit
b2186b67
authored
Feb 01, 2019
by
Mark Chao
Committed by
Bob Van Landuyt
Feb 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add DISTINCT to reduce query
Use ActiveRecord::Base to find max id
parent
8cc62f6c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
ee/db/migrate/20190114040405_consume_remaining_migrate_approver_to_approval_rules_in_batch_jobs.rb
...ining_migrate_approver_to_approval_rules_in_batch_jobs.rb
+6
-2
No files found.
ee/db/migrate/20190114040405_consume_remaining_migrate_approver_to_approval_rules_in_batch_jobs.rb
View file @
b2186b67
...
...
@@ -18,7 +18,7 @@ class ConsumeRemainingMigrateApproverToApprovalRulesInBatchJobs < ActiveRecord::
# Without it a search for the next bad MR can timeout if that MR's id is really high.
BOUND_SIZE
=
1000000
BASE_QUERY
=
<<~
SQL
SELECT merge_requests.id FROM merge_requests
SELECT
DISTINCT
merge_requests.id FROM merge_requests
LEFT JOIN approval_merge_request_rules
ON merge_requests.id = approval_merge_request_rules.merge_request_id AND approval_merge_request_rules.code_owner IS FALSE
LEFT JOIN approvers
...
...
@@ -28,6 +28,10 @@ class ConsumeRemainingMigrateApproverToApprovalRulesInBatchJobs < ActiveRecord::
WHERE (approval_merge_request_rules.id IS NULL) AND (approvers.id IS NOT NULL OR approver_groups.id IS NOT NULL)
SQL
class
MergeRequest
<
ActiveRecord
::
Base
self
.
table_name
=
'merge_requests'
end
disable_ddl_transaction!
def
up
...
...
@@ -44,7 +48,7 @@ class ConsumeRemainingMigrateApproverToApprovalRulesInBatchJobs < ActiveRecord::
def
process_unmigrated
bad_ids
=
[]
max_id
=
ActiveRecord
::
Base
.
connection
.
exec_query
(
"SELECT id FROM merge_requests ORDER BY id desc LIMIT 1"
).
rows
.
dig
(
0
,
0
)
max_id
=
MergeRequest
.
maximum
(
:id
)
return
if
max_id
.
nil?
...
...
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