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
367a8955
Commit
367a8955
authored
Jul 20, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend background migration development guidelines
parent
001dd56e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
doc/development/background_migrations.md
doc/development/background_migrations.md
+30
-0
No files found.
doc/development/background_migrations.md
View file @
367a8955
...
...
@@ -31,6 +31,18 @@ It's also possible for different migrations to be executed at the same time.
This means that different background migrations should not migrate data in a
way that would cause conflicts.
## Idempotence
Background migrations are executed in a context of a Sidekiq process.
Usual Sidekiq rules apply, especially the rule that jobs should be small
and idempotent.
See
[
Sidekiq best practices guidelines
](
https://github.com/mperham/sidekiq/wiki/Best-Practices
)
for more details.
Make sure that in case that your migration job is going to be retried a data
integrity is guarateed.
## How It Works
Background migrations are simple classes that define a
`perform`
method. A
...
...
@@ -212,3 +224,21 @@ end
This migration will then process any jobs for the ExtractServicesUrl migration
and continue once all jobs have been processed. Once done you can safely remove
the
`services.properties`
column.
## Testing
It is possible to test a background migrations scheduling migration and a
cleanup migration using
`:migration`
RSpec tag. See README in specs/migration/
directory.
When you do that, keep in mind that
`before`
and
`after`
RSpec hooks are going
to migrate you database down and up, which can result in another background
migrations being called. That means that using
`spy`
test doubles with
`have_received`
is encouraged, instead of using regular test doubles, because
your expectation defined in a
`it`
block can conflict with what is being
called in RSpec hooks. See gitlab-org/gitlab-ce#35351 for more details.
## Best practices
1.
Make sure that background migration jobs are idempotent.
1.
Make sure that tests you write are not false positives.
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