Skip to content

Backfill the missing wiki permissions in the main index

What does this MR do and why?

Backfill the visibility_access and wiki_access_level for wiki_blob in the main index. This is a preliminary requirement to achieve moving the wiki_blobs to the separate index.

The time for completion(internal link) of the migration is roughly 10 minutes.

Screenshots or screen recordings

After adding visibility_access and wiki_access_level for wiki_blob in the main index: Screenshot_2023-04-06_at_13.50.09

How to set up and validate locally

  1. Make sure you have advanced search enabled. Go to the admin settings. And check the boxes Elasticsearch indexing and Search with Elasticsearch enabled
  2. Make sure you have Project Wiki in your gdk. If not then switch to master and create one.
  3. Run the query on local Elasticsearch:
GET gitlab-development/_count
{
  "query": {
    "bool": {
      "must_not": {
        "exists": {
          "field": "wiki_access_level"
        }
      },
      "must": {
        "terms": {
          "type": [
            "wiki_blob"
          ]
        }
      }
    }
  }
}

Notice in the response that count should be non-zero.

  1. Now open the Rails console
bundle exec rails c

Run the following command

require_relative 'ee/elastic/migrate/20230405500000_backfill_wiki_permissions_in_main_index.rb' 
BackfillWikiPermissionsInMainIndex.new(20230405500000).migrate
  1. Now, again run the above Elastic query and notice in the response that count should be 0
  2. Second thing to test is if you create a new wiki then it should already have visibility_access and wiki_access_level. You can test by creating a new project wiki and without running the migration in the console, run the elastic query above and verify the count is 0

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 #404693 (closed)

Edited by Ravi Kumar

Merge request reports

Loading