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
73d31251
Commit
73d31251
authored
Sep 18, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure all stages are migrated after a cleanup
parent
9106975d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
db/migrate/20170912113435_clean_stages_statuses_migration.rb
db/migrate/20170912113435_clean_stages_statuses_migration.rb
+11
-0
spec/migrations/clean_stages_statuses_migration_spec.rb
spec/migrations/clean_stages_statuses_migration_spec.rb
+16
-0
No files found.
db/migrate/20170912113435_clean_stages_statuses_migration.rb
View file @
73d31251
...
...
@@ -5,8 +5,19 @@ class CleanStagesStatusesMigration < ActiveRecord::Migration
disable_ddl_transaction!
class
Stage
<
ActiveRecord
::
Base
include
::
EachBatch
self
.
table_name
=
'ci_stages'
end
def
up
Gitlab
::
BackgroundMigration
.
steal
(
'MigrateStageStatus'
)
Stage
.
where
(
'status IS NULL'
).
each_batch
(
of:
50
)
do
|
batch
|
range
=
batch
.
pluck
(
'MIN(id)'
,
'MAX(id)'
).
first
Gitlab
::
BackgroundMigration
::
MigrateStageStatus
.
new
.
perform
(
*
range
)
end
end
def
down
...
...
spec/migrations/clean_stages_statuses_migration_spec.rb
View file @
73d31251
...
...
@@ -23,6 +23,7 @@ describe CleanStagesStatusesMigration, :migration, :sidekiq, :redis do
end
end
end
context
'when there are no background migrations pending'
do
it
'does nothing'
do
Sidekiq
::
Testing
.
disable!
do
...
...
@@ -32,4 +33,19 @@ describe CleanStagesStatusesMigration, :migration, :sidekiq, :redis do
end
end
end
context
'when there are still unmigrated stages afterwards'
do
let
(
:stages
)
{
table
(
'ci_stages'
)
}
before
do
stages
.
create!
(
status:
nil
,
name:
'build'
)
stages
.
create!
(
status:
nil
,
name:
'test'
)
end
it
'migrates statuses sequentially in batches'
do
migrate!
expect
(
migration
).
to
have_received
(
:perform
).
once
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