Sha256: 5bb5d45c94b01e2a5b635045707c7d8ac1c97e4470eda3c2eee92abd3412bbfc

Contents?: true

Size: 730 Bytes

Versions: 1

Compression:

Stored size: 730 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 if tenant != "public"
      end
    end
  rescue PG::ConnectionBad, ActiveRecord::NoDatabaseError
    # no-op if there is no database setup
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
canvas_sync-0.7.1 config/initializers/apartment.rb