Skip to content
This repository has been archived by the owner on Jan 23, 2019. It is now read-only.

Latest commit

 

History

History
109 lines (78 loc) · 4.52 KB

README.rdoc

File metadata and controls

109 lines (78 loc) · 4.52 KB

WARNING: The Project Has Been Suspended

Please note, that this project has been suspended. No updates will be provided and no Rails versions beyond 3.2.x will be supported. For more information please check out this blog post: kovyrin.net/2014/11/14/dbcharmer-suspended/

DB Charmer - ActiveRecord Connection Magic Plugin

DbCharmer is a simple yet powerful plugin for ActiveRecord that significantly extends its ability to work with multiple databases and/or database servers. The major features we add to ActiveRecord are:

  1. Simple management for AR model connections (switch_connection_to method)

  2. Switching of default AR model connections to separate servers/databases

  3. Ability to easily choose where your query should go (Model.on_* methods family)

  4. Automated master/slave queries routing (selects go to a slave, updates handled by the master).

  5. Multiple database migrations with very flexible query routing controls.

  6. Simple database sharding functionality with multiple sharding methods (value, range, mapping table).

For more information on the project, you can check out our web site at kovyrin.github.io/db-charmer/.

Installation

There are two options when approaching DbCharmer installation:

  • using the gem (recommended and the only way of using it with Rails 3.2+)

  • install as a Rails plugin (works in Rails 2.x only)

To install as a gem, add this to your Gemfile:

gem 'db-charmer', :require => 'db_charmer'

To install DbCharmer as a Rails plugin use the following command:

./script/plugin install git://github.com/kovyrin/db-charmer.git

Notice: If you use DbCharmer in a non-rails project, you may need to set DbCharmer.env to a correct value before using any of its connection management methods. Correct value here is a valid database.yml first-level section name.

Documentation/Questions

For more information about the library, please visit our site at dbcharmer.net. If you need more defails on DbCharmer internals, please check out the source code. All the plugin’s code is ~100% covered with tests. The project located in test-project directory has unit tests for all or, at least, the most actively used code paths.

If you have any questions regarding this project, you could contact the author using the DbCharmer Users Group mailing list:

What Ruby and Rails implementations does it work for?

We have a continuous integration setup for this gem on with Rails 2.3, 3.0, 3.1 and 3.2 using a few different versions of Ruby.

CI is running on TravisCI.org: travis-ci.org/kovyrin/db-charmer Build status is: <img src=“https://secure.travis-ci.org/kovyrin/db-charmer.png?branch=master” alt=“Build Status: Rails 3.x” />

At the moment we have the following build matrix:

  • Rails versions:

    • 2.3

    • 3.0

    • 3.1

    • 3.2

  • Ruby versions:

    • 1.8.7

    • 1.9.3 (Rails 3.0+ only)

    • 2.0.0 (Rails 3.2+ only)

  • Databases:

    • MySQL

In addition to CI testing, this gem is used in production on Scribd.com (one of the largest RoR sites in the world) with Ruby Enterprise Edition and Rails 2.2, Rails 2.3, Sinatra and plain Rack applications.

Starting with version 1.8.0 we support Rails versions 3.2.8 and higher. Please note, that Rails 3.2.4 is not officially supported. Your code may work on that version, but no bug reports will be accepted about this version.

Is it Thread-Safe?

Starting with version 1.9.0 we have started working on making the code thread-safe and making sure DbCharmer works correctly in multi-threaded environments. At this moment we consider multi-threaded mode experimental. If you use it and it works for you - please let us know, if it does not - please make sure to file a ticket so that we could improve the code and make it work in your situation.

Who are the authors?

This plugin has been created in Scribd.com for our internal use and then the sources were opened for other people to use. Most of the code in this package has been developed by Oleksiy Kovyrin for Scribd.com and is released under the MIT license. For more details, see the LICENSE file.

Other contributors who have helped with the development of this library are (alphabetically ordered):

  • Allen Madsen

  • Andrew Geweke

  • Ashley Martens

  • Cauê Guerra

  • David Dai

  • Dmytro Shteflyuk

  • Eric Lindvall

  • Eugene Pimenov

  • Jonathan Viney

  • Gregory Man

  • Michael Birk

  • Tyler McMullen