debian-mirror-gitlab/lib/gitlab/background_migration/backfill_topics_title.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
683 B
Ruby
Raw Normal View History

2022-07-16 23:28:13 +05:30
# frozen_string_literal: true
module Gitlab
module BackgroundMigration
# The class to backfill the topic title
class BackfillTopicsTitle
# Temporary AR model for topics
class Topic < ActiveRecord::Base
self.table_name = 'topics'
end
def perform(start_id, end_id)
Topic.where(id: start_id..end_id).where(title: nil).update_all('title = name')
mark_job_as_succeeded(start_id, end_id)
end
private
def mark_job_as_succeeded(*arguments)
::Gitlab::Database::BackgroundMigrationJob.mark_all_as_succeeded(
self.class.name.demodulize,
arguments
)
end
end
end
end