Enable a Rails application to have separate databases for each tenant.
Enable a Rails application to have separate databases for each tenant.
Enable a Rails application to host multiple isolated tenants.
[!NOTE] Only the sqlite3 database adapter is fully supported right now. If you have a use case for tenanting one of the other databases supported by Rails, please reach out to the maintainers!
A "multi-tenant application" can be informally defined as:
... a single instance of a software application (and its underlying database and hardware) serv[ing] multiple tenants (or user accounts).
A tenant can be an individual user, but more frequently, it’s a group of users — such as a customer organization — that shares common access to and privileges within the application instance. Each tenant’s data is isolated from, and invisible to, the other tenants sharing the application instance, ensuring data security and privacy for all tenants.
This gem's design is rooted in a few guiding principles in order to safely allow multiple tenants to share a Rails application instance:
Another guiding principle, though, is:
Your code shouldn't have to know about tenanting! The hope is that you will rarely need to think about managing tenant isolation, and that as long as you're following Rails conventions, this gem and the framework will keep your tenants' data safe.
This gem extends or integrates tightly with Rails to ensure that any data persisted or transmitted happens within an isolated tenant context — without developers having to think about it.
Install the gem and add to the application's Gemfile by executing:
bundle add activerecord-tenantedFor detailed configuration and usage, see GUIDE.md.
Bug reports and pull requests are welcome on GitHub at https://github.com/basecamp/activerecord-tenanted. The tests are split between:
bin/test-unitbin/test-integrationFor a full test feedback loop, run bin/ci.
The gem is available as open source under the terms of the MIT License.
No open issues yet, or sync has not completed.