Skip to content

Create a migration to backfill the archived field in milestone

Ravi Kumar requested to merge 421464-migration-backfill-archived-milestone into master

What does this MR do and why?

This migration will backfill the archived value for the milestones.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

  1. Make sure the Elasticsearch is enabled.
  2. Open the rails console
bundle exec rails c
  1. Run the following commands in the console.
require_relative 'ee/elastic/migrate/20230831152648_backfill_archived_on_milestones.rb' 
BackfillArchivedOnNotes.new(20230831152648).migrate
  1. Check on the elastic that all the notes must have the archived. To check that run the following curl command on the terminal and make sure the count is 0
curl -XGET "http://localhost:9200/gitlab-development/_count" -H "kbn-xsrf: reporting" -H "Content-Type: application/json" -d'
{
  "query": {
    "bool": {
      "must_not": {
        "exists": {
          "field": "archived"
        }
      },
      "filter": {
        "term": {
          "type": "milestone"
        }
      }
    }
  }
}' | json_pp

Run time

~5 minutes

[1] pry(main)> batch_size = 9_000
=> 9000
[2] pry(main)> throttle_delay = 10.seconds
=> 10 seconds
[3] pry(main)> number_of_documents = 278_023
=> 278023
[4] pry(main)> (number_of_documents / batch_size) * throttle_delay
=> 300 seconds
=> ~ 5 minutes

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #421464 (closed)

#423863 (closed)

Edited by Ravi Kumar

Merge request reports

Loading