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
7f45515d
Commit
7f45515d
authored
Aug 30, 2021
by
Jonas Wälter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reschedule 'ExtractProjectTopicsIntoSeparateTable' post migration
Changelog: fixed
parent
8f4b7c72
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
5 deletions
+35
-5
db/post_migrate/20210830104800_reschedule_extract_project_topics_into_separate_table.rb
..._reschedule_extract_project_topics_into_separate_table.rb
+18
-0
db/schema_migrations/20210830104800
db/schema_migrations/20210830104800
+1
-0
lib/gitlab/background_migration/extract_project_topics_into_separate_table.rb
...d_migration/extract_project_topics_into_separate_table.rb
+13
-4
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/20210830104800_reschedule_extract_project_topics_into_separate_table.rb
0 → 100644
View file @
7f45515d
# frozen_string_literal: true
class
RescheduleExtractProjectTopicsIntoSeparateTable
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
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/20210830104800
0 → 100644
View file @
7f45515d
84a68304f95ae04b85625c214b28a251014582fb142390ff3df8ea6d6f0947e1
\ No newline at end of file
lib/gitlab/background_migration/extract_project_topics_into_separate_table.rb
View file @
7f45515d
...
...
@@ -26,12 +26,21 @@ module Gitlab
belongs_to
:topic
end
# Temporary AR table for projects
class
Project
<
ActiveRecord
::
Base
self
.
table_name
=
'projects'
end
def
perform
(
start_id
,
stop_id
)
Tagging
.
includes
(
:tag
).
where
(
taggable_type:
'Project'
,
id:
start_id
..
stop_id
).
each
do
|
tagging
|
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?
if
Project
.
exists?
(
id:
tagging
.
taggable_id
)
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?
else
tagging
.
delete
end
end
mark_job_as_succeeded
(
start_id
,
stop_id
)
...
...
spec/lib/gitlab/background_migration/extract_project_topics_into_separate_table_spec.rb
View file @
7f45515d
...
...
@@ -21,14 +21,16 @@ RSpec.describe Gitlab::BackgroundMigration::ExtractProjectTopicsIntoSeparateTabl
tagging_2
=
taggings
.
create!
(
taggable_type:
'Project'
,
taggable_id:
project
.
id
,
context:
'topics'
,
tag_id:
tag_2
.
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_4
=
taggings
.
create!
(
taggable_type:
'Project'
,
taggable_id:
-
1
,
context:
'topics'
,
tag_id:
tag_1
.
id
)
subject
.
perform
(
tagging_1
.
id
,
tagging_
3
.
id
)
subject
.
perform
(
tagging_1
.
id
,
tagging_
4
.
id
)
# Tagging records
expect
{
tagging_1
.
reload
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
expect
{
tagging_2
.
reload
}.
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_4
.
reload
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
# Topic records
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