Commit 01ef8c75 authored by Steve Abrams's avatar Steve Abrams

Merge branch '335794-cleanup-old-taggings' into 'master'

Cleanup unused tagging records

See merge request gitlab-org/gitlab!73260
parents 200f9851 2cd94915
# frozen_string_literal: true
class TmpIndexForDeleteIssueMergeRequestTaggingsRecords < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
INDEX_NAME = 'tmp_index_taggings_on_id_where_taggable_type_issue_mr'
INDEX_CONDITION = "taggable_type IN ('Issue', 'MergeRequest')"
def up
add_concurrent_index :taggings, :id, where: INDEX_CONDITION, name: INDEX_NAME # rubocop:disable Migration/PreventIndexCreation
end
def down
remove_concurrent_index_by_name :taggings, INDEX_NAME
end
end
# frozen_string_literal: true
class DeleteIssueMergeRequestTaggingsRecords < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
INDEX_NAME = 'tmp_index_taggings_on_id_where_taggable_type_issue_mr'
BATCH_SIZE = 3_000
TAGGABLE_TYPES = %w(Issue MergeRequest)
def up
sleep 2 while ActsAsTaggableOn::Tagging.where(taggable_type: TAGGABLE_TYPES).limit(BATCH_SIZE).delete_all > 0
remove_concurrent_index_by_name :taggings, INDEX_NAME
end
def down
end
end
bb28267d020cbc26614e4635c803af0168ab5606f3aadc40e1c0e0bc6d988254
\ No newline at end of file
27578f62b5cde4fdbfe79eb717404a5cef62b8c17170525428dbf81e6b394ce9
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment