diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2018-03-06 15:20:20 +0100 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2018-04-25 10:53:37 +0200 |
commit | 5bb421ecbbfdf4658c8e3bfb05dc86a84c7e4725 (patch) | |
tree | 4ce30ce0d5ea50b5ece218f8b5126ceb980345aa /db | |
parent | e6f6f8e7a3af3cd577075d1ac9ce287867c3e429 (diff) | |
download | gitlab-ce-5bb421ecbbfdf4658c8e3bfb05dc86a84c7e4725.tar.gz |
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')
-rw-r--r-- | db/migrate/20180425131009_assure_commits_count_for_merge_request_diff.rb | 27 | ||||
-rw-r--r-- | db/schema.rb | 2 |
2 files changed, 28 insertions, 1 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 diff --git a/db/schema.rb b/db/schema.rb index dc4607d0876..5853b428430 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180418053107) do +ActiveRecord::Schema.define(version: 20180425131009) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" |