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
56dd119f
Commit
56dd119f
authored
Sep 16, 2021
by
Jonas Wälter
Committed by
Heinrich Lee Yu
Sep 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reschedule 'ExtractProjectTopicsIntoSeparateTable' bg migration (2)
parent
766c7741
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
6 deletions
+29
-6
db/post_migrate/20210909104800_reschedule_extract_project_topics_into_separate_table_2.rb
...eschedule_extract_project_topics_into_separate_table_2.rb
+16
-0
db/schema_migrations/20210909104800
db/schema_migrations/20210909104800
+1
-0
lib/gitlab/background_migration/extract_project_topics_into_separate_table.rb
...d_migration/extract_project_topics_into_separate_table.rb
+9
-5
spec/lib/gitlab/background_migration/extract_project_topics_into_separate_table_spec.rb
...ration/extract_project_topics_into_separate_table_spec.rb
+3
-1
No files found.
db/post_migrate/20210909104800_reschedule_extract_project_topics_into_separate_table_2.rb
0 → 100644
View file @
56dd119f
# frozen_string_literal: true
class
RescheduleExtractProjectTopicsIntoSeparateTable2
<
Gitlab
::
Database
::
Migration
[
1.0
]
MIGRATION
=
'ExtractProjectTopicsIntoSeparateTable'
DELAY_INTERVAL
=
4
.
minutes
disable_ddl_transaction!
def
up
requeue_background_migration_jobs_by_range_at_intervals
(
MIGRATION
,
DELAY_INTERVAL
)
end
def
down
# no-op
end
end
db/schema_migrations/20210909104800
0 → 100644
View file @
56dd119f
834825de758314db01a3daa2d2b943c11751553705c4dd078f2087b9ec6ff7f7
\ No newline at end of file
lib/gitlab/background_migration/extract_project_topics_into_separate_table.rb
View file @
56dd119f
...
@@ -33,11 +33,15 @@ module Gitlab
...
@@ -33,11 +33,15 @@ module Gitlab
def
perform
(
start_id
,
stop_id
)
def
perform
(
start_id
,
stop_id
)
Tagging
.
includes
(
:tag
).
where
(
taggable_type:
'Project'
,
id:
start_id
..
stop_id
).
each
do
|
tagging
|
Tagging
.
includes
(
:tag
).
where
(
taggable_type:
'Project'
,
id:
start_id
..
stop_id
).
each
do
|
tagging
|
if
Project
.
exists?
(
id:
tagging
.
taggable_id
)
if
Project
.
exists?
(
id:
tagging
.
taggable_id
)
&&
tagging
.
tag
topic
=
Topic
.
find_or_create_by
(
name:
tagging
.
tag
.
name
)
begin
project_topic
=
ProjectTopic
.
find_or_create_by
(
project_id:
tagging
.
taggable_id
,
topic:
topic
)
topic
=
Topic
.
find_or_create_by
(
name:
tagging
.
tag
.
name
)
project_topic
=
ProjectTopic
.
find_or_create_by
(
project_id:
tagging
.
taggable_id
,
topic:
topic
)
tagging
.
delete
if
project_topic
.
persisted?
tagging
.
delete
if
project_topic
.
persisted?
rescue
StandardError
=>
e
Gitlab
::
ErrorTracking
.
log_exception
(
e
,
tagging_id:
tagging
.
id
)
end
else
else
tagging
.
delete
tagging
.
delete
end
end
...
...
spec/lib/gitlab/background_migration/extract_project_topics_into_separate_table_spec.rb
View file @
56dd119f
...
@@ -22,8 +22,9 @@ RSpec.describe Gitlab::BackgroundMigration::ExtractProjectTopicsIntoSeparateTabl
...
@@ -22,8 +22,9 @@ RSpec.describe Gitlab::BackgroundMigration::ExtractProjectTopicsIntoSeparateTabl
other_tagging
=
taggings
.
create!
(
taggable_type:
'Other'
,
taggable_id:
project
.
id
,
context:
'topics'
,
tag_id:
tag_1
.
id
)
other_tagging
=
taggings
.
create!
(
taggable_type:
'Other'
,
taggable_id:
project
.
id
,
context:
'topics'
,
tag_id:
tag_1
.
id
)
tagging_3
=
taggings
.
create!
(
taggable_type:
'Project'
,
taggable_id:
project
.
id
,
context:
'topics'
,
tag_id:
tag_3
.
id
)
tagging_3
=
taggings
.
create!
(
taggable_type:
'Project'
,
taggable_id:
project
.
id
,
context:
'topics'
,
tag_id:
tag_3
.
id
)
tagging_4
=
taggings
.
create!
(
taggable_type:
'Project'
,
taggable_id:
-
1
,
context:
'topics'
,
tag_id:
tag_1
.
id
)
tagging_4
=
taggings
.
create!
(
taggable_type:
'Project'
,
taggable_id:
-
1
,
context:
'topics'
,
tag_id:
tag_1
.
id
)
tagging_5
=
taggings
.
create!
(
taggable_type:
'Project'
,
taggable_id:
project
.
id
,
context:
'topics'
,
tag_id:
-
1
)
subject
.
perform
(
tagging_1
.
id
,
tagging_
4
.
id
)
subject
.
perform
(
tagging_1
.
id
,
tagging_
5
.
id
)
# Tagging records
# Tagging records
expect
{
tagging_1
.
reload
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
expect
{
tagging_1
.
reload
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
...
@@ -31,6 +32,7 @@ RSpec.describe Gitlab::BackgroundMigration::ExtractProjectTopicsIntoSeparateTabl
...
@@ -31,6 +32,7 @@ RSpec.describe Gitlab::BackgroundMigration::ExtractProjectTopicsIntoSeparateTabl
expect
{
other_tagging
.
reload
}.
not_to
raise_error
(
ActiveRecord
::
RecordNotFound
)
expect
{
other_tagging
.
reload
}.
not_to
raise_error
(
ActiveRecord
::
RecordNotFound
)
expect
{
tagging_3
.
reload
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
expect
{
tagging_3
.
reload
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
expect
{
tagging_4
.
reload
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
expect
{
tagging_4
.
reload
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
expect
{
tagging_5
.
reload
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
# Topic records
# Topic records
topic_1
=
topics
.
find_by
(
name:
'Topic1'
)
topic_1
=
topics
.
find_by
(
name:
'Topic1'
)
...
...
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