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
952e5b34
Commit
952e5b34
authored
Nov 04, 2021
by
dfrazao-gitlab
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add back user_mentions background migration
parent
206967e9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
0 deletions
+62
-0
config/feature_flags/development/migrate_user_mentions.yml
config/feature_flags/development/migrate_user_mentions.yml
+11
-0
lib/gitlab/background_migration/user_mentions/create_resource_user_mention.rb
...d_migration/user_mentions/create_resource_user_mention.rb
+36
-0
spec/lib/gitlab/background_migration/user_mentions/create_resource_user_mention_spec.rb
...ration/user_mentions/create_resource_user_mention_spec.rb
+15
-0
No files found.
config/feature_flags/development/migrate_user_mentions.yml
0 → 100644
View file @
952e5b34
---
# While this FF is enabled by default, we want to keep it in place for now as there are still related migrations that
# have not been run in production yet. For additional info, see https://gitlab.com/gitlab-org/gitlab/-/issues/21801
# Discussion and removal MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60322
name
:
migrate_user_mentions
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/34378
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/231175
milestone
:
'
13.3'
type
:
development
group
:
group::project management
default_enabled
:
true
lib/gitlab/background_migration/user_mentions/create_resource_user_mention.rb
0 → 100644
View file @
952e5b34
# frozen_string_literal: true
# rubocop:disable Style/Documentation
module
Gitlab
module
BackgroundMigration
module
UserMentions
class
CreateResourceUserMention
# Resources that have mentions to be migrated:
# issue, merge_request, epic, commit, snippet, design
BULK_INSERT_SIZE
=
1_000
ISOLATION_MODULE
=
'Gitlab::BackgroundMigration::UserMentions::Models'
def
perform
(
resource_model
,
join
,
conditions
,
with_notes
,
start_id
,
end_id
)
return
unless
Feature
.
enabled?
(
:migrate_user_mentions
,
default_enabled:
true
)
resource_model
=
"
#{
ISOLATION_MODULE
}
::
#{
resource_model
}
"
.
constantize
if
resource_model
.
is_a?
(
String
)
model
=
with_notes
?
Gitlab
::
BackgroundMigration
::
UserMentions
::
Models
::
Note
:
resource_model
resource_user_mention_model
=
resource_model
.
user_mention_model
records
=
model
.
joins
(
join
).
where
(
conditions
).
where
(
id:
start_id
..
end_id
)
records
.
each_batch
(
of:
BULK_INSERT_SIZE
)
do
|
records
|
mentions
=
[]
records
.
each
do
|
record
|
mention_record
=
record
.
build_mention_values
(
resource_user_mention_model
.
resource_foreign_key
)
mentions
<<
mention_record
unless
mention_record
.
blank?
end
resource_user_mention_model
.
insert_all
(
mentions
)
unless
mentions
.
empty?
end
end
end
end
end
end
spec/lib/gitlab/background_migration/user_mentions/create_resource_user_mention_spec.rb
0 → 100644
View file @
952e5b34
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Gitlab
::
BackgroundMigration
::
UserMentions
::
CreateResourceUserMention
,
schema:
20181228175414
do
context
'checks no_quote_columns'
do
it
'has correct no_quote_columns'
do
expect
(
Gitlab
::
BackgroundMigration
::
UserMentions
::
Models
::
MergeRequest
.
no_quote_columns
).
to
match
([
:note_id
,
:merge_request_id
])
end
it
'commit has correct no_quote_columns'
do
expect
(
Gitlab
::
BackgroundMigration
::
UserMentions
::
Models
::
Commit
.
no_quote_columns
).
to
match
([
:note_id
])
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