Skip to content

Releases: basecamp/activerecord-tenanted

v0.6.0

05 Nov 16:02
e409f75

Choose a tag to compare

v0.6.0 / 2025-11-05

Breaking change: Rake tasks

Some rake task changes to rename tasks for the database name (like Rails does it):

  • db:migrate:DBNAME replaces db:migrate:tenant and db:migrate:tenant:all
    • it operates on all tenants by default
    • if there are no tenants it will create a database for the default tenant
    • the ARTENANT env var can be specified to run against a specific tenant
  • db:drop:DBNAME replaces db:drop:tenant
    • it operates on all tenants by default
    • NEW: the ARTENANT env var can be specified to run against a specific tenant
  • db:reset:DBNAME replaces db:reset:tenant
    • it operates on all tenants by default
    • NEW: the ARTENANT env var can be specified to run against a specific tenant
  • Tenanted::DatabaseTasks.base_config has been removed

Some additional changes:

  • Tenanted::DatabaseTasks is now a class that takes a tenanted base config as a constructor parameter.
  • ActiveRecord::Tenanted.base_configs is a new utility method that returns all the tenanted base configs for the current environment.

Breaking change: SQL query logging

Recent cascading changes on Rails main related to structured logging have made it challenging to continue to support log output like this:

# old log structure
Account Count [tenant=686465299] (0.1ms)  SELECT COUNT(*) FROM "accounts"

This version of the gem moves to using a query log tag named :tenant, which is more in line with how Rails wants extensions to inject content into the query logs. To use it, set this in your application config:

Rails.application.config.active_record.query_log_tags_enabled = true
Rails.application.config.active_record.query_log_tags = [ :tenant ]

When configured, the application will emit logs like this:

# new log structure
Account Count (0.3ms)  SELECT COUNT(*) FROM "accounts" /*tenant='686465299'*/

Read the Rails Guide documentation on config.active_record.query_log_tags for more information on query logs in general.

Added

  • UntenantedConnectionPool#size returns the database configuration's max_connections value, so that code (like Solid Queue) can inspect config params without a tenant context.

Full Changelog: v0.5.0...v0.6.0

v0.5.0 / 2025-10-12

12 Oct 18:31
4e7389d

Choose a tag to compare

v0.5.0 / 2025-10-12

Fixed

Changed

  • The return value from an Active Record model #cache_key has changed from users/1?tenant=foo to foo/users/1. For existing applications, this will invalidate any relevant cache entries. #187 @miguelmarcondesf
  • Renamed ActiveRecord::Tenanted::DatabaseTasks.tenanted_config to .base_config.

Improved

New Contributors

Full Changelog: v0.4.1...v0.5.0

v0.4.1 / 2025-09-17

12 Oct 18:27
b4d521e

Choose a tag to compare

v0.4.1 / 2025-09-17

Note that the v0.4.0 and v0.4.1 releases are functionally identical.

Added

  • Introduce max_connection_pools database configuration to limit the number of tenanted databases with open connections. Pools are reaped in least-recently-used order. #182 @flavorjones
  • Documentation: Improved GUIDE.md. @flavorjones

Changed

  • Rename ActiveRecord::Tenanted::DatabaseConfigurations::RootConfig to BaseConfig. @flavorjones
  • Rails dependency bumped to >= 8.1.beta #172 @andrewmarkle

0.3.0

09 Sep 20:49
0d873d8

Choose a tag to compare

0.3.0 / 2025-09-09

Improved

  • #inspect on instances of tenanted models includes the tenant. #155 @miguelmarcondesf @flavorjones
  • TenantSelector middleware no longer directly renders a 404. Instead, it configures ActionDispatch::ShowExceptions middlware and raises an appropriate exception. #167 @flavorjones