Skip to content

[STORE] Warn that the ActiveRecord persistence pattern is deprecated #809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 4, 2018

Conversation

estolfo
Copy link
Contributor

@estolfo estolfo commented Jun 29, 2018

No description provided.

@holidayworking
Copy link

Why the ActiveRecord Pattern is deprecated?

@karmi
Copy link
Contributor

karmi commented Jun 30, 2018

Hi @holidayworking, it's a consequence of multiple forces we have seen both when working in the codebase and in the practical usage, our own and in the wild.

As much as the ActiveRecord pattern is attractive for a quick start with persisting objects, particularly in Rails-based applications, we do see "impedance mismatches" between a storage like Elasticsearch and the ActiveRecord semantics, ranging from technical issues like consistency guarantees to conceptual ones like too tight coupling of business logic with the persistence details.

Particularly in our own internal use of the elasticsearch-persistence Rubygem, we have observed a much cleaner separation of concerns when using the Repository pattern. That particular persistence pattern is much more flexible in a larger codebase, while still being quite simple to use — in the end, you initialize a repository and then pass objects to it:

repository = Elasticsearch::Persistence::Repository.new
repository.save(my_object)

We are quite keen to explore and extend this pattern much more in the elasticsearch-persistence Rubygem, and we plan to refactor the example to provide thorough, code-based instructions for people how to migrate between this patterns.

Please note that this applies to the persistence library only: the integration with Ruby models (ActiveModel/ActiveRecord) doesn't go away, quite the opposite — we do plan to start fixing the outstanding issues on that front.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants