blob: 7e79c89203a669ccf325ef238e07e1d8e19059d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# frozen_string_literal: true
class ScheduleMergeTopicsWithSameName < Gitlab::Database::Migration[1.0]
MIGRATION = 'MergeTopicsWithSameName'
BATCH_SIZE = 100
disable_ddl_transaction!
class Topic < ActiveRecord::Base
self.table_name = 'topics'
end
def up
Topic.select('LOWER(name) as name').group('LOWER(name)').having('COUNT(*) > 1').order('LOWER(name)')
.in_groups_of(BATCH_SIZE, false).each_with_index do |group, i|
migrate_in((i + 1) * 2.minutes, MIGRATION, [group.map(&:name)])
end
end
def down
# no-op
end
end
|