Sha256: 318be9173a96c9781527cc202dfcba59dc71b7f2bf1f5464ea763025e387f0da

Contents?: true

Size: 708 Bytes

Versions: 65

Compression:

Stored size: 708 Bytes

Contents

# Resolve an issue where the wrong sequence name is used when
# importing data with Apartment and ActiveRecord::Import.
# See:
#   * https://github.com/zdennis/activerecord-import/issues/233
#   * https://github.com/influitive/apartment/issues/508

Rails.application.config.after_initialize do
  begin
    Rails.application.eager_load!
    ActiveRecord::Base.descendants.each do |model|
      seq_name = model.sequence_name
      if seq_name.present?
        tenant, seq_name = seq_name.include?(".") ? seq_name.split(".") : [nil, seq_name]
        model.sequence_name = seq_name
      end
    end
  rescue PG::ConnectionBad, ActiveRecord::NoDatabaseError
    # no-op if there is no database setup
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
canvas_sync-0.17.10.beta1 config/initializers/apartment.rb
canvas_sync-0.17.8 config/initializers/apartment.rb
canvas_sync-0.17.8.beta4 config/initializers/apartment.rb
canvas_sync-0.17.8.beta3 config/initializers/apartment.rb
canvas_sync-0.17.8.beta2 config/initializers/apartment.rb
canvas_sync-0.17.8.beta1 config/initializers/apartment.rb
canvas_sync-0.17.7 config/initializers/apartment.rb
canvas_sync-0.17.7.beta1 config/initializers/apartment.rb
canvas_sync-0.17.6 config/initializers/apartment.rb
canvas_sync-0.17.6.beta1 config/initializers/apartment.rb
canvas_sync-0.17.5 config/initializers/apartment.rb
canvas_sync-0.17.5.beta2 config/initializers/apartment.rb
canvas_sync-0.17.5.beta1 config/initializers/apartment.rb
canvas_sync-0.17.4 config/initializers/apartment.rb
canvas_sync-0.17.3.beta3 config/initializers/apartment.rb
canvas_sync-0.17.3.beta2 config/initializers/apartment.rb
canvas_sync-0.17.3.beta1 config/initializers/apartment.rb
canvas_sync-0.17.2 config/initializers/apartment.rb
canvas_sync-0.17.1 config/initializers/apartment.rb
canvas_sync-0.17.0 config/initializers/apartment.rb