summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-13 15:09:21 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-13 15:09:21 +0000
commitc36152ff8c41fad2f413f253eb7ac5c927e47c56 (patch)
treebbf300da207de3e8bbf272d44111ceedb18f5833 /lib
parent286fe61013674fe2d245ffc8d2233baf09923e70 (diff)
downloadgitlab-ce-c36152ff8c41fad2f413f253eb7ac5c927e47c56.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/background_migration/user_mentions/models/epic.rb1
-rw-r--r--lib/gitlab/import_export/fast_hash_serializer.rb6
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/gitlab/background_migration/user_mentions/models/epic.rb b/lib/gitlab/background_migration/user_mentions/models/epic.rb
index a76391d64bb..dc2b7819800 100644
--- a/lib/gitlab/background_migration/user_mentions/models/epic.rb
+++ b/lib/gitlab/background_migration/user_mentions/models/epic.rb
@@ -18,6 +18,7 @@ module Gitlab
self.table_name = 'epics'
belongs_to :author, class_name: "User"
+ belongs_to :project
belongs_to :group
def self.user_mention_model
diff --git a/lib/gitlab/import_export/fast_hash_serializer.rb b/lib/gitlab/import_export/fast_hash_serializer.rb
index 5a067b5c9f3..c6ecf13ded8 100644
--- a/lib/gitlab/import_export/fast_hash_serializer.rb
+++ b/lib/gitlab/import_export/fast_hash_serializer.rb
@@ -136,6 +136,12 @@ module Gitlab
data = []
record.in_batches(of: @batch_size) do |batch| # rubocop:disable Cop/InBatches
+ # order each batch by it's primary key to ensure
+ # consistent and predictable ordering of each exported relation
+ # as additional `WHERE` clauses can impact the order in which data is being
+ # returned by database when no `ORDER` is specified
+ batch = batch.reorder(batch.klass.primary_key)
+
if Feature.enabled?(:export_fast_serialize_with_raw_json, default_enabled: true)
data.append(JSONBatchRelation.new(batch, options, preloads[key]).tap(&:raw_json))
else