Skip to content

Finalize background migration for discussion IDs

Heinrich Lee Yu requested to merge 346495-finalize-discussion-id-migration into master

What does this MR do and why?

Finalizes the background migration added in 15.0: !78555 (merged)

Related to #346495 (closed), #357581 (closed)

We don't have any more notes with NULL discussion_id on staging and production:

gitlabhq_dblab=# SELECT COUNT(*) FROM notes WHERE discussion_id IS NULL;
 count
-------
     0
(1 row)
[ gstg ] production> Note.where(discussion_id: nil).count
=> 0

Migration output

== 20220524074947 FinalizeBackfillNullNoteDiscussionIds: migrating ============
== 20220524074947 FinalizeBackfillNullNoteDiscussionIds: migrated (0.0247s) ===

== 20220524081955 RemoveNotesNullDiscussionIdTempIndex: migrating =============
-- transaction_open?()
   -> 0.0000s
-- indexes(:notes)
   -> 0.0048s
-- execute("SET statement_timeout TO 0")
   -> 0.0003s
-- remove_index(:notes, {:algorithm=>:concurrently, :name=>"tmp_index_notes_on_id_where_discussion_id_is_null"})
   -> 0.0055s
-- execute("RESET statement_timeout")
   -> 0.0005s
== 20220524081955 RemoveNotesNullDiscussionIdTempIndex: migrated (0.0178s) ====

-- Current migration is skipped since it modifies '[:gitlab_main]' which is outside of '[:gitlab_ci, :gitlab_shared]'
== 20220524081955 RemoveNotesNullDiscussionIdTempIndex: migrating =============
-- transaction_open?()
   -> 0.0000s
-- indexes(:notes)
   -> 0.0096s
-- execute("SET statement_timeout TO 0")
   -> 0.0003s
-- remove_index(:notes, {:algorithm=>:concurrently, :name=>"tmp_index_notes_on_id_where_discussion_id_is_null"})
   -> 0.0077s
-- execute("RESET statement_timeout")
   -> 0.0003s
== 20220524081955 RemoveNotesNullDiscussionIdTempIndex: migrated (0.0230s) ====

== 20220524081955 RemoveNotesNullDiscussionIdTempIndex: reverting =============
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:notes, :id, {:where=>"discussion_id IS NULL", :name=>"tmp_index_notes_on_id_where_discussion_id_is_null", :algorithm=>:concurrently})
   -> 0.0077s
-- execute("SET statement_timeout TO 0")
   -> 0.0003s
-- add_index(:notes, :id, {:where=>"discussion_id IS NULL", :name=>"tmp_index_notes_on_id_where_discussion_id_is_null", :algorithm=>:concurrently})
   -> 0.0069s
-- execute("RESET statement_timeout")
   -> 0.0003s
== 20220524081955 RemoveNotesNullDiscussionIdTempIndex: reverted (0.0210s) ====

== 20220524074947 FinalizeBackfillNullNoteDiscussionIds: reverting ============
== 20220524074947 FinalizeBackfillNullNoteDiscussionIds: reverted (0.0000s) ===

MR acceptance checklist

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

Edited by Heinrich Lee Yu

Merge request reports

Loading