Set and maintain archived in notes index
What does this MR do and why?
This MR is setting the boolean archived field value for the notes index if the migration add_archived_to_notes is finished. Also setting elastic_index_dependant_association on notes to synch the archived values in the notes index.
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
- Ensure Elasticsearch is enabled in the gdk
Case migration add_archived_to_notes is not finished
- To simulate this case make an early return here
      def migration_has_finished?(name)
        return false if name.eql?(:add_archived_to_notes)
        Rails.cache.fetch cache_key(:migration_has_finished, name.to_s.underscore), expires_in: CACHE_TIMEOUT do
          migration_has_finished_uncached?(name)
        end
      end- Create a new note on any project item like an issue, merge_request
- Check the Elastic that the new note should not have an archivedfield
- Now archive that project, and again check on Elastic, the archivedfield still should not be present for this note
- Again unarchive the project and make sure on Elastic, the archivedfield still should not be present for this note
Case migration add_archived_to_notes is finished
- To be sure the migration is finished, run the following commands in the rails console. To start the rails console run the following command.
bundle exec rails c- Now in the console run the following commands
require_relative 'ee/elastic/migrate/20230719142200_add_archived_to_notes.rb'
AddArchivedToNotes.new(20230719142200).migrate- Create a new note on any project item like an issue, merge_request
- Check the Elastic that the new note should have an archivedfield
- Now archive that project, and again check on Elastic, the archivedfield should be set totrue
- Again unarchivethe project and make sure on Elastic, thearchivedfield should be set tofalse
This is a curl request you can use to check the note. Replace the project_id with the one you used for the testing
curl -XGET "http://localhost:9200/gitlab-development-notes/_search" -H "kbn-xsrf: reporting" -H "Content-Type: application/json" -d'
{
  "query": {
    "bool": {
      "filter": {
        "term": {
          "project_id": #{project_id}
        }
      }
    }
  }
}' | json_ppMR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
- 
I have evaluated the MR acceptance checklist for this MR. 
Related to #414905 (closed)
Edited  by Ravi Kumar