From 5b6375fc7366e94750887893f97c2d792ec55292 Mon Sep 17 00:00:00 2001 From: Dillon Welch Date: Wed, 17 Oct 2018 18:55:13 -0700 Subject: [PATCH 1/2] Add section about bulk_import Closes https://github.com/zdennis/activerecord-import/issues/505 --- README.markdown | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.markdown b/README.markdown index 0a481c3e..e9b42c67 100644 --- a/README.markdown +++ b/README.markdown @@ -26,6 +26,7 @@ an 18 hour batch process to <2 hrs. * [Callbacks](#callbacks) * [Additional Adapters](#additional-adapters) * [Load Path Setup](#load-path-setup) +* [Conflicts With Other Gems](#conflicts-with-other-gems) * [More Information](#more-information) ### Callbacks @@ -105,6 +106,11 @@ activerecord-import-fake_name/ When rubygems pushes the `lib` folder onto the load path a `require` will now find `activerecord-import/active_record/adapters/fake_name_adapter` as it runs through the lookup process for a ruby file under that path in `$LOAD_PATH` + +### Conflicts With Other Gems + +`activerecord-import` adds the `.import` method onto `ActiveRecord::Base`. There are other gems, such as `elasticsearch-rails`, that do the same thing. In conflicts such as this, there is an aliased method named `.bulk_import` that can be used interchangeably. + ### More Information For more information on activerecord-import please see its wiki: https://github.com/zdennis/activerecord-import/wiki From 6ee22d4cc9835b8dfcd50277a1a23044376e1358 Mon Sep 17 00:00:00 2001 From: Dillon Welch Date: Wed, 17 Oct 2018 19:24:13 -0700 Subject: [PATCH 2/2] Add notes about Apartment gem Closes https://github.com/zdennis/activerecord-import/issues/233 --- README.markdown | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.markdown b/README.markdown index e9b42c67..42ea1952 100644 --- a/README.markdown +++ b/README.markdown @@ -111,6 +111,29 @@ When rubygems pushes the `lib` folder onto the load path a `require` will now fi `activerecord-import` adds the `.import` method onto `ActiveRecord::Base`. There are other gems, such as `elasticsearch-rails`, that do the same thing. In conflicts such as this, there is an aliased method named `.bulk_import` that can be used interchangeably. +If you are using the `apartment` gem, there is a weird triple interaction between that gem, `activerecord-import`, and `activerecord` involving caching of the `sequence_name` of a model. This can be worked around by explcitly setting this value within the model. For example: + +```ruby +class Post < ActiveRecord::Base + self.sequence_name = "posts_seq" +end +``` + +Another way to work around the issue is to call `.reset_sequence_name` on the model. For example: + +```ruby +schemas.all.each do |schema| + Apartment::Tenant.switch! schema.name + ActiveRecord::Base.transaction do + Post.reset_sequence_name + + Post.import posts + end +end +``` + +See https://github.com/zdennis/activerecord-import/issues/233 for further discussion. + ### More Information For more information on activerecord-import please see its wiki: https://github.com/zdennis/activerecord-import/wiki