Every backend switches tenant together, or none of them do.
ConsoleKit points SQL, MongoDB, Redis and Elasticsearch at one tenant inside your Rails console, checks each backend really moved, and restores the previous tenant if any step fails.
[ConsoleKit]--- Multiple tenants detected. Please choose one: --- 0. Skip (load without tenant configuration) 1. acme (partner: acme) 2. globex (partner: globex)[ConsoleKit] Selection (number or name) [1]: acme[ConsoleKit] Establishing SQL connection to shard: shard_acme via ApplicationRecord[ConsoleKit] Switching to Redis DB: 1[ConsoleKit] Setting Elasticsearch index prefix: acme[ConsoleKit] [✓] Tenant initialized: acme[ConsoleKit] [✗] !!! CAUTION: YOU ARE IN PRODUCTION ENVIRONMENT !!![ConsoleKit] Active connections: SQL, MongoDB, Redis, Elasticsearch[acme] main:001> Order.count=> 1842
ConsoleKit¶
A simple and flexible multi-tenant console setup toolkit for Rails applications.
ConsoleKit helps you manage tenant-specific database connections (SQL, MongoDB, Redis, Elasticsearch) and context configuration via an easy CLI interface and Rails integration.
Compatibility¶
Every combination below is exercised by CI on each push - 24 cells, all of them required.
| Rails | Ruby |
|---|---|
| 6.1 | 3.2, 3.3, 3.4, 4.0 |
| 7.0 | 3.2, 3.3, 3.4, 4.0 |
| 7.1 | 3.2, 3.3, 3.4, 4.0 |
| 7.2 | 3.2, 3.3, 3.4, 4.0 |
| 8.0 | 3.2, 3.3, 3.4, 4.0 |
| 8.1 | 3.2, 3.3, 3.4, 4.0 |
The gem requires Ruby >= 3.2 and Rails >= 6.1, with no upper bound on either.
Installation¶
Install the gem and add to the application's Gemfile by executing:
bundle add console_kit
Additionally you can also add this line to your application's Gemfile:
gem 'console_kit'
And then execute:
bundle install
If bundler is not being used to manage dependencies, install the gem by executing:
gem install console_kit