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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
3eba43b6
Commit
3eba43b6
authored
Aug 23, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust a range and a size in stages statuses migration
parent
d546f7d3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
7 deletions
+8
-7
db/post_migrate/20170711145558_migrate_stages_statuses.rb
db/post_migrate/20170711145558_migrate_stages_statuses.rb
+4
-4
spec/migrations/migrate_stages_statuses_spec.rb
spec/migrations/migrate_stages_statuses_spec.rb
+4
-3
No files found.
db/post_migrate/20170711145558_migrate_stages_statuses.rb
View file @
3eba43b6
...
...
@@ -6,7 +6,7 @@ class MigrateStagesStatuses < ActiveRecord::Migration
disable_ddl_transaction!
BATCH_SIZE
=
10000
RANGE_SIZE
=
10
00
RANGE_SIZE
=
5
00
MIGRATION
=
'MigrateStageStatus'
.
freeze
class
Stage
<
ActiveRecord
::
Base
...
...
@@ -17,10 +17,10 @@ class MigrateStagesStatuses < ActiveRecord::Migration
def
up
Stage
.
where
(
status:
nil
).
each_batch
(
of:
BATCH_SIZE
)
do
|
relation
,
index
|
relation
.
each_batch
(
of:
RANGE_SIZE
)
do
|
batch
|
range
=
relation
.
pluck
(
'MIN(id)'
,
'MAX(id)'
).
first
schedule
=
index
*
5
.
minutes
range
=
batch
.
pluck
(
'MIN(id)'
,
'MAX(id)'
).
first
delay
=
index
*
5
.
minutes
BackgroundMigrationWorker
.
perform_in
(
schedule
,
MIGRATION
,
range
)
BackgroundMigrationWorker
.
perform_in
(
delay
,
MIGRATION
,
range
)
end
end
end
...
...
spec/migrations/migrate_stages_statuses_spec.rb
View file @
3eba43b6
...
...
@@ -12,7 +12,7 @@ describe MigrateStagesStatuses, :migration do
before
do
stub_const
(
"
#{
described_class
.
name
}
::BATCH_SIZE"
,
2
)
stub_const
(
"
#{
described_class
.
name
}
::RANGE_SIZE"
,
2
)
stub_const
(
"
#{
described_class
.
name
}
::RANGE_SIZE"
,
1
)
projects
.
create!
(
id:
1
,
name:
'gitlab1'
,
path:
'gitlab1'
)
projects
.
create!
(
id:
2
,
name:
'gitlab2'
,
path:
'gitlab2'
)
...
...
@@ -50,9 +50,10 @@ describe MigrateStagesStatuses, :migration do
Timecop
.
freeze
do
migrate!
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
5
.
minutes
,
1
,
2
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
5
.
minutes
,
1
,
1
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
5
.
minutes
,
2
,
2
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
10
.
minutes
,
3
,
3
)
expect
(
BackgroundMigrationWorker
.
jobs
.
size
).
to
eq
2
expect
(
BackgroundMigrationWorker
.
jobs
.
size
).
to
eq
3
end
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