bulkrax 3.0.0.beta2 → 3.0.0.beta5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c05782edcfff4b5c460c3cc3bd8b3fbec355299a87c977b0400b2b555105de8
4
- data.tar.gz: dd0316f5502afcea91ac0fa84f0ea6bcb1600aff9b867d5460e934aeafdaa9c2
3
+ metadata.gz: 994ee06cdd4ed63d0dfa79e0e77b1fb6b017528926a7b891d8ff702a15cf7347
4
+ data.tar.gz: 55298f93ce2078f1157a1426ce63823b78ae8a04cd4b076947a2ba1ad93ad05c
5
5
  SHA512:
6
- metadata.gz: fc72772040076f6e527adc335cb4dd6802c199f3b0e94ea81fab7d341d9354973fe76c08b9873e90d7244dd527617c60f0486e141736a589df2afd8e051bcd37
7
- data.tar.gz: 3c39be004fd6196d8692643a567a73398a4cb4105a1174535f73cbf7b515b8ca0d6a2bbc8cdb05c012dca814f5bc5b57ab5bfc40a6191ec73fcd40c96eb3e630
6
+ metadata.gz: 512b254802875cca2dae6377a1317439b25d35038aacd56ce2db18ee2aaaf9d0f1d22bb2f521ce16366a7a5630d5768468f3949579216fc02502b36e06e6159a
7
+ data.tar.gz: b25f1d98da59db8bc91f02d90fe44003350d7bf7eb7b67d5610d2006f7e0f5e1b72e9d37601b3a41f01faf34c8c07d8c388e173084edc6ebaf985e5f124f7d4a
@@ -7,10 +7,10 @@ module Bulkrax
7
7
  include DynamicRecordLookup
8
8
 
9
9
  define_model_callbacks :save, :create
10
- attr_reader :attributes, :object, :source_identifier_value, :klass, :replace_files, :update_files, :work_identifier, :related_parents_parsed_mapping
10
+ attr_reader :attributes, :object, :source_identifier_value, :klass, :replace_files, :update_files, :work_identifier, :related_parents_parsed_mapping, :importer_run_id
11
11
 
12
12
  # rubocop:disable Metrics/ParameterLists
13
- def initialize(attributes:, source_identifier_value:, work_identifier:, related_parents_parsed_mapping: nil, replace_files: false, user: nil, klass: nil, update_files: false)
13
+ def initialize(attributes:, source_identifier_value:, work_identifier:, related_parents_parsed_mapping: nil, replace_files: false, user: nil, klass: nil, importer_run_id: nil, update_files: false)
14
14
  @attributes = ActiveSupport::HashWithIndifferentAccess.new(attributes)
15
15
  @replace_files = replace_files
16
16
  @update_files = update_files
@@ -19,6 +19,7 @@ module Bulkrax
19
19
  @related_parents_parsed_mapping = related_parents_parsed_mapping
20
20
  @source_identifier_value = source_identifier_value
21
21
  @klass = klass || Bulkrax.default_work_type.constantize
22
+ @importer_run_id = importer_run_id
22
23
  end
23
24
  # rubocop:enable Metrics/ParameterLists
24
25
 
@@ -137,23 +138,25 @@ module Bulkrax
137
138
  end
138
139
 
139
140
  def create_collection(attrs)
141
+ attrs = clean_attrs(attrs)
140
142
  attrs = collection_type(attrs)
141
- persist_collection_memberships(parent: find_collection(attributes[related_parents_parsed_mapping]), child: object) if attributes[related_parents_parsed_mapping].present?
142
143
  object.attributes = attrs
143
144
  object.apply_depositor_metadata(@user)
144
145
  object.save!
146
+ pass_collection_to_be_persisted(parent: find_collection(attributes[related_parents_parsed_mapping]), child: object) if attributes[related_parents_parsed_mapping].present?
145
147
  end
146
148
 
147
149
  def update_collection(attrs)
148
- persist_collection_memberships(parent: find_collection(attributes[related_parents_parsed_mapping]), child: object) if attributes[related_parents_parsed_mapping].present?
149
150
  object.attributes = attrs
150
151
  object.save!
152
+ pass_collection_to_be_persisted(parent: find_collection(attributes[related_parents_parsed_mapping]), child: object) if attributes[related_parents_parsed_mapping].present?
151
153
  end
152
154
 
153
155
  # This method is heavily inspired by Hyrax's AttachFilesToWorkJob
154
156
  def create_file_set(attrs)
155
- work = find_record(attributes[related_parents_parsed_mapping].first)
157
+ _, work = find_record(attributes[related_parents_parsed_mapping].first, importer_run_id)
156
158
  work_permissions = work.permissions.map(&:to_hash)
159
+ attrs = clean_attrs(attrs)
157
160
  file_set_attrs = attrs.slice(*object.attributes.keys)
158
161
  object.assign_attributes(file_set_attrs)
159
162
 
@@ -179,9 +182,17 @@ module Bulkrax
179
182
  actor.update_metadata(file_set_attrs)
180
183
  end
181
184
 
185
+ def pass_collection_to_be_persisted(parent:, child:)
186
+ if parent.is_a? Array
187
+ parent.each { |par| persist_collection_memberships(par, child) }
188
+ else
189
+ persist_collection_memberships(parent, child)
190
+ end
191
+ end
192
+
182
193
  # Add child to parent's #member_collections
183
194
  # Add parent to child's #member_of_collections
184
- def persist_collection_memberships(parent:, child:)
195
+ def persist_collection_memberships(parent, child)
185
196
  parent.reject!(&:blank?) if parent.respond_to?(:reject!)
186
197
  child.reject!(&:blank?) if child.respond_to?(:reject!)
187
198
  return if parent.blank? || child.blank?
@@ -202,8 +213,16 @@ module Bulkrax
202
213
  end
203
214
  end
204
215
 
216
+ def clean_attrs(attrs)
217
+ # avoid the "ArgumentError: Identifier must be a string of size > 0 in order to be treeified" error
218
+ # when setting object.attributes
219
+ attrs.delete('id') if attrs['id'].blank?
220
+ attrs
221
+ end
222
+
205
223
  def collection_type(attrs)
206
224
  return attrs if attrs['collection_type_gid'].present?
225
+
207
226
  attrs['collection_type_gid'] = Hyrax::CollectionType.find_or_create_default_collection_type.gid
208
227
  attrs
209
228
  end
@@ -21,7 +21,7 @@ module Bulkrax
21
21
 
22
22
  queue_as :import
23
23
 
24
- attr_accessor :child_records, :parent_record, :parent_entry, :importer_run_id
24
+ attr_accessor :child_records, :child_entry, :parent_record, :parent_entry, :importer_run_id
25
25
 
26
26
  # @param parent_identifier [String] Work/Collection ID or Bulkrax::Entry source_identifiers
27
27
  # @param importer_run [Bulkrax::ImporterRun] current importer run (needed to properly update counters)
@@ -31,17 +31,17 @@ module Bulkrax
31
31
  # Whether the @base_entry is the parent or the child in the relationship is determined by the presence of a
32
32
  # parent_identifier or child_identifier param. For example, if a parent_identifier is passed, we know @base_entry
33
33
  # is the child in the relationship, and vice versa if a child_identifier is passed.
34
- def perform(parent_identifier:, importer_run_id:)
34
+ def perform(parent_identifier:, importer_run_id:) # rubocop:disable Metrics/AbcSize
35
35
  pending_relationships = Bulkrax::PendingRelationship.find_each.select do |rel|
36
36
  rel.bulkrax_importer_run_id == importer_run_id && rel.parent_id == parent_identifier
37
37
  end.sort_by(&:order)
38
38
 
39
39
  @importer_run_id = importer_run_id
40
- @parent_record = find_record(parent_identifier)
40
+ @parent_entry, @parent_record = find_record(parent_identifier, importer_run_id)
41
41
  @child_records = { works: [], collections: [] }
42
42
  pending_relationships.each do |rel|
43
43
  raise ::StandardError, %("#{rel}" needs either a child or a parent to create a relationship) if rel.child_id.nil? || rel.parent_id.nil?
44
- child_record = find_record(rel.child_id)
44
+ @child_entry, child_record = find_record(rel.child_id, importer_run_id)
45
45
  child_record.is_a?(::Collection) ? @child_records[:collections] << child_record : @child_records[:works] << child_record
46
46
  end
47
47
 
@@ -53,13 +53,13 @@ module Bulkrax
53
53
  return false # stop current job from continuing to run after rescheduling
54
54
  end
55
55
 
56
- @parent_entry = Bulkrax::Entry.where(identifier: parent_identifier,
57
- importerexporter_id: ImporterRun.find(importer_run_id).importer_id,
58
- importerexporter_type: "Bulkrax::Importer").first
56
+ @parent_entry ||= Bulkrax::Entry.where(identifier: parent_identifier,
57
+ importerexporter_id: ImporterRun.find(importer_run_id).importer_id,
58
+ importerexporter_type: "Bulkrax::Importer").first
59
59
  create_relationships
60
60
  pending_relationships.each(&:destroy)
61
61
  rescue ::StandardError => e
62
- parent_entry.status_info(e)
62
+ parent_entry ? parent_entry.status_info(e) : child_entry.status_info(e)
63
63
  Bulkrax::ImporterRun.find(importer_run_id).increment!(:failed_relationships) # rubocop:disable Rails/SkipsModelValidations
64
64
  end
65
65
 
@@ -87,11 +87,12 @@ module Bulkrax
87
87
  ObjectFactory.new(
88
88
  attributes: attrs,
89
89
  source_identifier_value: nil, # sending the :id in the attrs means the factory doesn't need a :source_identifier_value
90
- work_identifier: parent_entry.parser.work_identifier,
91
- related_parents_parsed_mapping: parent_entry.parser.related_parents_parsed_mapping,
90
+ work_identifier: parent_entry&.parser&.work_identifier,
91
+ related_parents_parsed_mapping: parent_entry&.parser&.related_parents_parsed_mapping,
92
92
  replace_files: false,
93
93
  user: user,
94
- klass: child_record.class
94
+ klass: child_record.class,
95
+ importer_run_id: importer_run_id
95
96
  ).run
96
97
  # TODO: add counters for :processed_parents and :failed_parents
97
98
  Bulkrax::ImporterRun.find(importer_run_id).increment!(:processed_relationships) # rubocop:disable Rails/SkipsModelValidations
@@ -105,11 +106,12 @@ module Bulkrax
105
106
  ObjectFactory.new(
106
107
  attributes: attrs,
107
108
  source_identifier_value: nil, # sending the :id in the attrs means the factory doesn't need a :source_identifier_value
108
- work_identifier: parent_entry.parser.work_identifier,
109
- related_parents_parsed_mapping: parent_entry.parser.related_parents_parsed_mapping,
109
+ work_identifier: parent_entry&.parser&.work_identifier,
110
+ related_parents_parsed_mapping: parent_entry&.parser&.related_parents_parsed_mapping,
110
111
  replace_files: false,
111
112
  user: user,
112
- klass: parent_record.class
113
+ klass: parent_record.class,
114
+ importer_run_id: importer_run_id
113
115
  ).run
114
116
  # TODO: add counters for :processed_parents and :failed_parents
115
117
  Bulkrax::ImporterRun.find(importer_run_id).increment!(:processed_relationships) # rubocop:disable Rails/SkipsModelValidations
@@ -128,11 +130,12 @@ module Bulkrax
128
130
  ObjectFactory.new(
129
131
  attributes: attrs,
130
132
  source_identifier_value: nil, # sending the :id in the attrs means the factory doesn't need a :source_identifier_value
131
- work_identifier: parent_entry.parser.work_identifier,
132
- related_parents_parsed_mapping: parent_entry.parser.related_parents_parsed_mapping,
133
+ work_identifier: parent_entry&.parser&.work_identifier,
134
+ related_parents_parsed_mapping: parent_entry&.parser&.related_parents_parsed_mapping,
133
135
  replace_files: false,
134
136
  user: user,
135
- klass: parent_record.class
137
+ klass: parent_record.class,
138
+ importer_run_id: importer_run_id
136
139
  ).run
137
140
  # TODO: add counters for :processed_parents and :failed_parents
138
141
  Bulkrax::ImporterRun.find(importer_run_id).increment!(:processed_relationships) # rubocop:disable Rails/SkipsModelValidations
@@ -7,7 +7,10 @@ module Bulkrax
7
7
 
8
8
  queue_as :import
9
9
 
10
+ attr_reader :importer_run_id
11
+
10
12
  def perform(entry_id, importer_run_id)
13
+ @importer_run_id = importer_run_id
11
14
  entry = Entry.find(entry_id)
12
15
  parent_identifier = entry.raw_metadata[entry.related_parents_raw_mapping]&.strip
13
16
 
@@ -63,7 +66,8 @@ module Bulkrax
63
66
  end
64
67
 
65
68
  def find_parent_record(parent_identifier)
66
- @parent_record ||= find_record(parent_identifier)
69
+ @parent_record ||= find_record(parent_identifier, importer_run_id)
70
+ @parent_record = parent_record.last if parent_record.is_a? Array
67
71
  end
68
72
  end
69
73
  end
@@ -41,6 +41,8 @@ module Bulkrax
41
41
  self.parsed_metadata = {}
42
42
  add_identifier
43
43
  add_ingested_metadata
44
+ # TODO(alishaevn): remove the collections stuff entirely and only reference collections via the new parents code
45
+ add_collections
44
46
  add_visibility
45
47
  add_metadata_for_model
46
48
  add_rights_statement
@@ -238,35 +240,40 @@ module Bulkrax
238
240
  Bulkrax::CsvMatcher
239
241
  end
240
242
 
241
- def possible_collection_ids
242
- return @possible_collection_ids if @possible_collection_ids.present?
243
+ def collection_identifiers
244
+ return @collection_identifiers if @collection_identifiers.present?
243
245
 
244
- collection_field_mapping = self.class.parent_field(parser)
245
- return [] unless collection_field_mapping.present? && record[collection_field_mapping].present?
246
+ parent_field_mapping = self.class.parent_field(parser)
247
+ return [] unless parent_field_mapping.present? && record[parent_field_mapping].present?
246
248
 
247
249
  identifiers = []
248
- split_titles = record[collection_field_mapping].split(/\s*[;|]\s*/)
249
- split_titles.each do |c_title|
250
- matching_collection_entries = importerexporter.entries.select { |e| e.raw_metadata['title'] == c_title }
250
+ split_references = record[parent_field_mapping].split(/\s*[;|]\s*/)
251
+ split_references.each do |c_reference|
252
+ matching_collection_entries = importerexporter.entries.select do |e|
253
+ (e.raw_metadata[source_identifier] == c_reference) &&
254
+ e.is_a?(CsvCollectionEntry)
255
+ end
251
256
  raise ::StandardError, 'Only expected to find one matching entry' if matching_collection_entries.count > 1
252
257
  identifiers << matching_collection_entries.first&.identifier
253
258
  end
254
- @possible_collection_ids = identifiers.compact.presence || []
259
+
260
+ @collection_identifiers = identifiers.compact.presence || []
255
261
  end
256
262
 
257
263
  def collections_created?
258
- possible_collection_ids.length == self.collection_ids.length
264
+ collection_identifiers.length == self.collection_ids.length
259
265
  end
260
266
 
261
267
  def find_collection_ids
262
268
  return self.collection_ids if collections_created?
263
- if possible_collection_ids.present?
264
- possible_collection_ids.each do |collection_id|
269
+ if collection_identifiers.present?
270
+ collection_identifiers.each do |collection_id|
265
271
  c = find_collection(collection_id)
266
272
  skip = c.blank? || self.collection_ids.include?(c.id)
267
273
  self.collection_ids << c.id unless skip
268
274
  end
269
275
  end
276
+
270
277
  self.collection_ids
271
278
  end
272
279
 
@@ -4,5 +4,9 @@ module Bulkrax
4
4
  class ImporterRun < ApplicationRecord
5
5
  belongs_to :importer
6
6
  has_many :statuses, as: :runnable, dependent: :destroy
7
+
8
+ def parents
9
+ PendingRelationship.where(bulkrax_importer_run_id: id).pluck(:parent_id).uniq
10
+ end
7
11
  end
8
12
  end
@@ -6,9 +6,16 @@ module Bulkrax
6
6
  # has the provided identifier.
7
7
  #
8
8
  # @param identifier [String] Work/Collection ID or Bulkrax::Entry source_identifier
9
- # @return [Work, Collection, nil] Work or Collection if found, otherwise nil
10
- def find_record(identifier)
11
- record = Entry.find_by(identifier: identifier)
9
+ # @param importer_run_id [Number] ID of the current_run of this Importer Job
10
+ # @return [Entry, nil], [Work, Collection, nil] Entry if found, otherwise nil and a Work or Collection if found, otherwise nil
11
+ def find_record(identifier, importer_run_id = nil)
12
+ # check for our entry in our current importer first
13
+ importer_id = ImporterRun.find(importer_run_id).importer_id
14
+ default_scope = { identifier: identifier, importerexporter_type: 'Bulkrax::Importer' }
15
+ record = Entry.find_by(default_scope, importerexporter_id: importer_id) || Entry.find_by(default_scope)
16
+
17
+ # TODO(alishaevn): discuss whether we are only looking for Collection models here
18
+ # use ActiveFedora::Base.find(identifier) instead?
12
19
  record ||= ::Collection.where(id: identifier).first # rubocop:disable Rails/FindBy
13
20
  if record.blank?
14
21
  available_work_types.each do |work_type|
@@ -16,7 +23,9 @@ module Bulkrax
16
23
  end
17
24
  end
18
25
 
19
- record.is_a?(Entry) ? record.factory.find : record
26
+ # return the found entry here instead of searching for it again in the CreateRelationshipsJob
27
+ # also accounts for when the found entry isn't a part of this importer
28
+ record.is_a?(Entry) ? [record, record.factory.find] : [nil, record]
20
29
  end
21
30
 
22
31
  # Check if the record is a Work
@@ -45,6 +45,8 @@ module Bulkrax
45
45
  end
46
46
 
47
47
  def new_remote_files
48
+ return if object.is_a? FileSet
49
+
48
50
  @new_remote_files ||= if object.present? && object.file_sets.present?
49
51
  parsed_remote_files.select do |file|
50
52
  # is the url valid?
@@ -101,7 +103,12 @@ module Bulkrax
101
103
  end
102
104
 
103
105
  def local_file_sets
104
- @local_file_sets ||= object&.ordered_file_sets
106
+ @local_file_sets ||= ordered_file_sets
107
+ end
108
+
109
+ def ordered_file_sets
110
+ # OVERRIDE Hyrda-works 1.2.0 - this method was deprecated in v1.0
111
+ object&.ordered_members.to_a.select(&:file_set?)
105
112
  end
106
113
 
107
114
  def import_files
@@ -28,7 +28,6 @@ module Bulkrax
28
28
  self.parsed_metadata[related_parents_parsed_mapping].each do |parent_identifier|
29
29
  next if parent_identifier.blank?
30
30
 
31
- add_parent_to_import_run(parent_identifier, importerexporter.last_run)
32
31
  PendingRelationship.create!(child_id: self.identifier, parent_id: parent_identifier, bulkrax_importer_run_id: importerexporter.last_run.id, order: self.id)
33
32
  end
34
33
  end
@@ -37,17 +36,10 @@ module Bulkrax
37
36
  self.parsed_metadata[related_children_parsed_mapping].each do |child_identifier|
38
37
  next if child_identifier.blank?
39
38
 
40
- add_parent_to_import_run(self.identifier, importerexporter.last_run)
41
39
  PendingRelationship.create!(parent_id: self.identifier, child_id: child_identifier, bulkrax_importer_run_id: importerexporter.last_run.id, order: self.id)
42
40
  end
43
41
  end
44
42
 
45
- def add_parent_to_import_run(parent_id, run)
46
- run.parents = [] if run.parents.nil?
47
- run.parents << parent_id
48
- run.save
49
- end
50
-
51
43
  def find_collection_ids
52
44
  self.collection_ids
53
45
  end
@@ -99,6 +91,7 @@ module Bulkrax
99
91
  replace_files: replace_files,
100
92
  user: user,
101
93
  klass: factory_class,
94
+ importer_run_id: importerexporter.last_run.id,
102
95
  update_files: update_files)
103
96
  end
104
97
 
@@ -79,13 +79,12 @@
79
79
  <%= @exporter.exporter_runs.last&.total_work_entries %>
80
80
  </p>
81
81
  <br>
82
- <div class="bulkrax-nav-tab-table-left-align">
82
+ <div class='bulkrax-nav-tab-table-left-align'>
83
83
  <h2>Entries</h2>
84
84
  <table class='table table-striped'>
85
85
  <thead>
86
86
  <tr>
87
87
  <th>Identifier</th>
88
- <th>Collection</th>
89
88
  <th>Entry ID</th>
90
89
  <th>Status</th>
91
90
  <th>Errors</th>
@@ -97,17 +96,12 @@
97
96
  <% @work_entries.each do |e| %>
98
97
  <tr>
99
98
  <td><%= link_to e.identifier, bulkrax.exporter_entry_path(@exporter.id, e.id) %></td>
100
- <% if e.parsed_metadata.present? && e.parsed_metadata.dig('collections').present? %>
101
- <td><%= e.parsed_metadata.dig('collections').map {|c| c['id'] }.join('; ') %></td>
102
- <% elsif e.raw_metadata.present? %>
103
- <td><%= Array.wrap(e.raw_metadata.dig('collection')).join(';') %></td>
104
- <% else %>
105
- <td></td>
106
- <% end %>
107
99
  <td><%= e.id %></td>
108
100
  <% if e.status == 'Complete' %>
109
101
  <td><span class='glyphicon glyphicon-ok' style='color: green;'></span> <%= e.status %></td>
110
- <% else %>
102
+ <% elsif e.status == 'Pending' %>
103
+ <td><span class='glyphicon glyphicon-option-horizontal' style='color: blue;'></span> <%= e.status %></td>
104
+ <% else %>
111
105
  <td><span class='glyphicon glyphicon-remove' style='color: red;'></span> <%= e.status %></td>
112
106
  <% end %>
113
107
  <% if e.last_error.present? %>
@@ -85,7 +85,6 @@
85
85
  <thead>
86
86
  <tr>
87
87
  <th>Identifier</th>
88
- <th>Collection</th>
89
88
  <th>Entry ID</th>
90
89
  <th>Status</th>
91
90
  <th>Errors</th>
@@ -97,13 +96,6 @@
97
96
  <% @work_entries.each do |e| %>
98
97
  <tr>
99
98
  <td><%= link_to e.identifier, bulkrax.importer_entry_path(@importer.id, e.id) %></td>
100
- <% if e.parsed_metadata.present? && e.parsed_metadata.dig("collections").present? %>
101
- <td><%= e.parsed_metadata.dig("collections").map {|c| c['id'] }.join('; ') %></td>
102
- <% elsif e.raw_metadata.present? %>
103
- <td><%= Array.wrap(e.raw_metadata.dig("collection")).join(';') %></td>
104
- <% else %>
105
- <td></td>
106
- <% end %>
107
99
  <td><%= e.id %></td>
108
100
  <% if e.status == "Complete" %>
109
101
  <td><span class="glyphicon glyphicon-ok" style="color: green;"></span> <%= e.status %></td>
@@ -183,6 +175,8 @@
183
175
  <td><%= e.id %></td>
184
176
  <% if e.status == "Complete" %>
185
177
  <td><span class="glyphicon glyphicon-ok" style="color: green;"></span> <%= e.status %></td>
178
+ <% elsif e.status == "Pending" %>
179
+ <td><span class="glyphicon glyphicon-option-horizontal" style="color: blue;"></span> <%= e.status %></td>
186
180
  <% else %>
187
181
  <td><span class="glyphicon glyphicon-remove" style="color: red;"></span> <%= e.status %></td>
188
182
  <% end %>
@@ -1,6 +1,6 @@
1
1
  class RenameChildrenCountersToRelationships < ActiveRecord::Migration[5.2]
2
2
  def change
3
- rename_column :bulkrax_importer_runs, :processed_children, :processed_relationships
4
- rename_column :bulkrax_importer_runs, :failed_children, :failed_relationships
3
+ rename_column :bulkrax_importer_runs, :processed_children, :processed_relationships unless column_exists?(:bulkrax_importer_runs, :processed_relationships)
4
+ rename_column :bulkrax_importer_runs, :failed_children, :failed_relationships unless column_exists?(:bulkrax_importer_runs, :failed_relationships)
5
5
  end
6
6
  end
@@ -1,11 +1,13 @@
1
1
  class CreateBulkraxPendingRelationships < ActiveRecord::Migration[5.2]
2
2
  def change
3
- create_table :bulkrax_pending_relationships do |t|
4
- t.belongs_to :bulkrax_importer_run, foreign_key: true, null: false
5
- t.string :parent_id, null: false
6
- t.string :child_id, null: false
3
+ unless table_exists?(:bulkrax_pending_relationships)
4
+ create_table :bulkrax_pending_relationships do |t|
5
+ t.belongs_to :bulkrax_importer_run, foreign_key: true, null: false
6
+ t.string :parent_id, null: false
7
+ t.string :child_id, null: false
7
8
 
8
- t.timestamps
9
+ t.timestamps
10
+ end
9
11
  end
10
12
  end
11
13
  end
@@ -1,5 +1,5 @@
1
1
  class AddOrderToBulkraxPendingRelationships < ActiveRecord::Migration[5.2]
2
2
  def change
3
- add_column :bulkrax_pending_relationships, :order, :integer, default: 0
3
+ add_column :bulkrax_pending_relationships, :order, :integer, default: 0 unless column_exists?(:bulkrax_pending_relationships, :order)
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bulkrax
4
- VERSION = '3.0.0.beta2'
4
+ VERSION = '3.0.0.beta5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bulkrax
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.beta2
4
+ version: 3.0.0.beta5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Kaufman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-29 00:00:00.000000000 Z
11
+ date: 2022-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -366,7 +366,6 @@ files:
366
366
  - db/migrate/20220118001339_add_import_attempts_to_entries.rb
367
367
  - db/migrate/20220119213325_add_work_counters_to_importer_runs.rb
368
368
  - db/migrate/20220301001839_create_bulkrax_pending_relationships.rb
369
- - db/migrate/20220301020307_add_parents_to_bulkrax_importer_runs.rb
370
369
  - db/migrate/20220303212810_add_order_to_bulkrax_pending_relationships.rb
371
370
  - lib/bulkrax.rb
372
371
  - lib/bulkrax/engine.rb
@@ -1,5 +0,0 @@
1
- class AddParentsToBulkraxImporterRuns < ActiveRecord::Migration[5.1]
2
- def change
3
- add_column :bulkrax_importer_runs, :parents, :text, array: true
4
- end
5
- end