Sha256: 1d9a653ff1ff4e810fbf02694674b07e9da333006ed5f965ff93d4909656fd18
Contents?: true
Size: 1008 Bytes
Versions: 77
Compression:
Stored size: 1008 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 next unless defined?(Apartment) # Newer versions of Apartment already solves this issue (and in a better way) begin require('apartment/version') next if Gem::Version.new(Apartment::VERSION) >= Gem::Version.new('2.8.1') rescue LoadError end 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, ActiveRecord::ConnectionNotEstablished # no-op if there is no database setup end end
Version data entries
77 entries across 77 versions & 1 rubygems