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
95051ada
Commit
95051ada
authored
Apr 07, 2021
by
Markus Koller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add helper to delete queued background migrations when rescheduling
parent
38186b3c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
0 deletions
+33
-0
doc/development/background_migrations.md
doc/development/background_migrations.md
+8
-0
lib/gitlab/database/migrations/background_migration_helpers.rb
...itlab/database/migrations/background_migration_helpers.rb
+8
-0
spec/lib/gitlab/database/migrations/background_migration_helpers_spec.rb
.../database/migrations/background_migration_helpers_spec.rb
+17
-0
No files found.
doc/development/background_migrations.md
View file @
95051ada
...
...
@@ -142,6 +142,14 @@ migration performing the scheduling. Otherwise the background migration would be
scheduled multiple times on systems that are upgrading multiple patch releases at
once.
When you start the second post-deployment migration, you should delete any
previously queued jobs from the initial migration with the provided
helper:
```
ruby
delete_queued_jobs
(
'BackgroundMigrationClassName'
)
```
## Cleaning Up
NOTE:
...
...
lib/gitlab/database/migrations/background_migration_helpers.rb
View file @
95051ada
...
...
@@ -236,6 +236,14 @@ module Gitlab
Gitlab
::
ApplicationContext
.
with_context
(
caller_id:
self
.
class
.
to_s
,
&
block
)
end
def
delete_queued_jobs
(
class_name
)
Gitlab
::
BackgroundMigration
.
steal
(
class_name
)
do
|
job
|
job
.
delete
false
end
end
private
def
track_in_database
(
class_name
,
arguments
)
...
...
spec/lib/gitlab/database/migrations/background_migration_helpers_spec.rb
View file @
95051ada
...
...
@@ -431,4 +431,21 @@ RSpec.describe Gitlab::Database::Migrations::BackgroundMigrationHelpers do
model
.
bulk_migrate_in
(
10
.
minutes
,
[
%w(Class hello world)
])
end
end
describe
'#delete_queued_jobs'
do
let
(
:job1
)
{
double
}
let
(
:job2
)
{
double
}
it
'deletes all queued jobs for the given background migration'
do
expect
(
Gitlab
::
BackgroundMigration
).
to
receive
(
:steal
).
with
(
'BackgroundMigrationClassName'
)
do
|&
block
|
expect
(
block
.
call
(
job1
)).
to
be
(
false
)
expect
(
block
.
call
(
job2
)).
to
be
(
false
)
end
expect
(
job1
).
to
receive
(
:delete
)
expect
(
job2
).
to
receive
(
:delete
)
model
.
delete_queued_jobs
(
'BackgroundMigrationClassName'
)
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