Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Provaznik <jprovaznik@gitlab.com>2018-03-06 17:20:20 +0300
committerJan Provaznik <jprovaznik@gitlab.com>2018-04-25 11:53:37 +0300
commit5bb421ecbbfdf4658c8e3bfb05dc86a84c7e4725 (patch)
tree4ce30ce0d5ea50b5ece218f8b5126ceb980345aa /db/migrate/20180425131009_assure_commits_count_for_merge_request_diff.rb
parente6f6f8e7a3af3cd577075d1ac9ce287867c3e429 (diff)
Cleanup after adding MR diff's commit_count (try 2)
* processes any pending records which are not migrated yet * bumps import_export version because of new commits_count attribute * removes commits_count fallback method
Diffstat (limited to 'db/migrate/20180425131009_assure_commits_count_for_merge_request_diff.rb')
-rw-r--r--db/migrate/20180425131009_assure_commits_count_for_merge_request_diff.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/db/migrate/20180425131009_assure_commits_count_for_merge_request_diff.rb b/db/migrate/20180425131009_assure_commits_count_for_merge_request_diff.rb
new file mode 100644
index 00000000000..0e991c23bfa
--- /dev/null
+++ b/db/migrate/20180425131009_assure_commits_count_for_merge_request_diff.rb
@@ -0,0 +1,27 @@
+class AssureCommitsCountForMergeRequestDiff < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ class MergeRequestDiff < ActiveRecord::Base
+ self.table_name = 'merge_request_diffs'
+
+ include ::EachBatch
+ end
+
+ def up
+ Gitlab::BackgroundMigration.steal('AddMergeRequestDiffCommitsCount')
+
+ MergeRequestDiff.where(commits_count: nil).each_batch(of: 50) do |batch|
+ range = batch.pluck('MIN(id)', 'MAX(id)').first
+
+ Gitlab::BackgroundMigration::AddMergeRequestDiffCommitsCount.new.perform(*range)
+ end
+ end
+
+ def down
+ # noop
+ end
+end