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
02bb40e2
Commit
02bb40e2
authored
Jun 28, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Find builds that require a migration in batches
parent
6209ff67
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb
...0170628080858_migrate_stage_id_reference_in_background.rb
+6
-3
spec/migrations/migrate_stage_id_reference_in_background_spec.rb
...grations/migrate_stage_id_reference_in_background_spec.rb
+2
-0
No files found.
db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb
View file @
02bb40e2
...
...
@@ -2,6 +2,8 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
BATCH_SIZE
=
10000
MIGRATION
=
'MigrateBuildStageIdReference'
.
freeze
disable_ddl_transaction!
...
...
@@ -10,9 +12,10 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration
end
def
up
Build
.
find_each
do
|
build
|
BackgroundMigrationWorker
.
perform_async
(
'MigrateBuildStageIdReference'
,
[
build
.
id
])
Build
.
find_in_batches
(
batch_size:
BATCH_SIZE
).
with_index
do
|
builds
,
batch
|
migrations
=
builds
.
map
{
|
build
|
[
MIGRATION
,
[
build
.
id
]]
}
BackgroundMigrationWorker
.
perform_bulk
(
*
migrations
)
end
end
...
...
spec/migrations/migrate_stage_id_reference_in_background_spec.rb
View file @
02bb40e2
...
...
@@ -8,6 +8,8 @@ describe MigrateStageIdReferenceInBackground, :migration, :redis do
let
(
:projects
)
{
table
(
:projects
)
}
before
do
stub_const
(
'MigrateStageIdReferenceInBackground::BATCH_SIZE'
,
1
)
projects
.
create!
(
id:
123
,
name:
'gitlab1'
,
path:
'gitlab1'
)
pipelines
.
create!
(
id:
1
,
project_id:
123
,
ref:
'master'
,
sha:
'adf43c3a'
)
...
...
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