Activerecord Multi Tenant

screenshot of Activerecord Multi Tenant
rails

Rails/ActiveRecord support for distributed multi-tenant databases like Postgres+Citus

Overview

The activerecord-multi-tenant gem is a powerful tool designed for Ruby on Rails applications that require multi-tenancy support. Specifically optimized for PostgreSQL with the Citus extension, this gem enables developers to easily scale out multi-tenant applications by efficiently routing queries to appropriate database nodes. With streamlined installation and usage, it supports all Rails versions starting from 6.0 and provides a straightforward implementation process, making it accessible even for those new to multi-tenancy.

This gem simplifies the management of tenant contexts within applications, allowing for seamless operations across different tenants. It offers features such as write-only mode for handling tenant IDs and the ability to manage non-tenant-specific tables with ease, ensuring that your application can grow and adapt to various business needs without compromising on performance.

Features

  • Seamless Rails Integration: Works with Ruby on Rails versions 6.0 and up, making it compatible with the latest frameworks.
  • Efficient Query Routing: Automatically adds tenant context to queries, optimizing database routing in multi-tenant environments.
  • Write-Only Mode: Facilitates handling of tenant IDs for new records while allowing for a flexible approach to existing records.
  • Tenant Model Flexibility: No need for a defined tenant model; adapt easily by using tenant IDs and instances as required.
  • Support for Non-Tenant Tables: Provides guidance on managing tables that do not relate to tenants, ensuring clean data handling.
  • Easy Setup: Simple installation via a Gemfile, allowing developers to integrate quickly into their existing applications.
  • Background Task Support: Enables efficient backfilling of tenant IDs for existing records, streamlining the transition to multi-tenancy.
  • Community Backed: Based on established previous work, benefiting from collective improvements and robust testing.
rails
Ruby on Rails

Ruby on Rails, often referred to as Rails, is an open-source web application framework written in Ruby. Known for its convention over configuration and don't repeat yourself (DRY) principles, Rails simplifies and accelerates the development of database-backed web applications.