summaryrefslogtreecommitdiff
path: root/lib/gitlab/import_export/json_hash_builder.rb
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2017-06-09 12:48:25 +0100
committerSean McGivern <sean@gitlab.com>2017-06-16 18:30:01 +0100
commit9a73b634ab4220f68a8296ccb582a68293874489 (patch)
treef99d9eb55836dcdb54c18f72d4b1242a5d9acefa /lib/gitlab/import_export/json_hash_builder.rb
parent352a9ed56213b6f83a679e72f9554638a0aed1ee (diff)
downloadgitlab-ce-9a73b634ab4220f68a8296ccb582a68293874489.tar.gz
Add table for files in merge request diffs
This adds an ID-less table containing one row per file, per merge request diff. It has a column for each attribute on Gitlab::Git::Diff that is serialised currently, with the advantage that we can easily query the attributes of this new table. It does not migrate existing data, so we have fallback code when the legacy st_diffs column is present instead. For a merge request diff to be valid, it should have at most one of: * Rows in this new table, with the correct merge_request_diff_id. * A non-NULL st_diffs column. It may have neither, if the diff is empty.
Diffstat (limited to 'lib/gitlab/import_export/json_hash_builder.rb')
-rw-r--r--lib/gitlab/import_export/json_hash_builder.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/gitlab/import_export/json_hash_builder.rb b/lib/gitlab/import_export/json_hash_builder.rb
index 48c09dafcb6..b48f63bcd7e 100644
--- a/lib/gitlab/import_export/json_hash_builder.rb
+++ b/lib/gitlab/import_export/json_hash_builder.rb
@@ -83,7 +83,9 @@ module Gitlab
# +value+ existing model to be included in the hash
# +json_config_hash+ the original hash containing the root model
def add_model_value(current_key, value, json_config_hash)
- @attributes_finder.parse(value) { |hash| value = { value => hash } }
+ @attributes_finder.parse(value) do |hash|
+ value = { value => hash } unless value.is_a?(Hash)
+ end
add_to_array(current_key, json_config_hash, value)
end