diff options
Diffstat (limited to 'db/post_migrate/20220913030624_cleanup_attention_request_related_system_notes.rb')
-rw-r--r-- | db/post_migrate/20220913030624_cleanup_attention_request_related_system_notes.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/db/post_migrate/20220913030624_cleanup_attention_request_related_system_notes.rb b/db/post_migrate/20220913030624_cleanup_attention_request_related_system_notes.rb new file mode 100644 index 00000000000..b7d6908696b --- /dev/null +++ b/db/post_migrate/20220913030624_cleanup_attention_request_related_system_notes.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +class CleanupAttentionRequestRelatedSystemNotes < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + restrict_gitlab_migration gitlab_schema: :gitlab_main + + BATCH_SIZE = 100 + + class SystemNoteMetadata < MigrationRecord + include EachBatch + + self.table_name = 'system_note_metadata' + end + + class Note < MigrationRecord + self.table_name = 'notes' + end + + def up + SystemNoteMetadata + .where(action: %w[attention_requested attention_request_removed]) + .each_batch(of: BATCH_SIZE) do |batch| + Note.where(id: batch.pluck(:note_id)).delete_all + end + end + + def down + # no op + end +end |