diff options
Diffstat (limited to 'db/post_migrate/20210302074524_backfill_namespace_statistics_with_wiki_size.rb')
-rw-r--r-- | db/post_migrate/20210302074524_backfill_namespace_statistics_with_wiki_size.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/db/post_migrate/20210302074524_backfill_namespace_statistics_with_wiki_size.rb b/db/post_migrate/20210302074524_backfill_namespace_statistics_with_wiki_size.rb new file mode 100644 index 00000000000..e04f69f4206 --- /dev/null +++ b/db/post_migrate/20210302074524_backfill_namespace_statistics_with_wiki_size.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class BackfillNamespaceStatisticsWithWikiSize < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + DELAY_INTERVAL = 2.minutes.to_i + BATCH_SIZE = 500 + MIGRATION = 'PopulateNamespaceStatistics' + + disable_ddl_transaction! + + def up + return unless Gitlab.ee? + + groups = exec_query <<~SQL + SELECT group_wiki_repositories.group_id + FROM group_wiki_repositories + SQL + + groups.rows.flatten.in_groups_of(BATCH_SIZE, false).each_with_index do |group_ids, index| + migrate_in(index * DELAY_INTERVAL, MIGRATION, [group_ids, [:wiki_size]]) + end + end + + def down + # No-op + end +end |