Releases: basecamp/activerecord-tenanted
v0.6.0
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:DBNAMEreplacesdb:migrate:tenantanddb: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
ARTENANTenv var can be specified to run against a specific tenant
db:drop:DBNAMEreplacesdb:drop:tenant- it operates on all tenants by default
- NEW: the
ARTENANTenv var can be specified to run against a specific tenant
db:reset:DBNAMEreplacesdb:reset:tenant- it operates on all tenants by default
- NEW: the
ARTENANTenv var can be specified to run against a specific tenant
Tenanted::DatabaseTasks.base_confighas been removed
Some additional changes:
Tenanted::DatabaseTasksis now a class that takes a tenanted base config as a constructor parameter.ActiveRecord::Tenanted.base_configsis 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#sizereturns the database configuration'smax_connectionsvalue, 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
v0.5.0 / 2025-10-12
Fixed
- Handle the new parallel testing behavior introduced by rails/rails#55769, unblocking Rails edge upgrades. #216 @flavorjones
Changed
- The return value from an Active Record model
#cache_keyhas changed fromusers/1?tenant=footofoo/users/1. For existing applications, this will invalidate any relevant cache entries. #187 @miguelmarcondesf - Renamed
ActiveRecord::Tenanted::DatabaseTasks.tenanted_configto.base_config.
Improved
- SQLite-specific code has been extracted into an adapter object. #204 #215 @andrewmarkle @flavorjones
- For tenanted model instances,
#inspectnow outputs the tenant attribute first, before the column attributes. #191 @lairtonmendes - The
debuggem is now available during testing. #200 @andrewmarkle
New Contributors
- @lairtonmendes made their first contribution in #191
Full Changelog: v0.4.1...v0.5.0
v0.4.1 / 2025-09-17
v0.4.1 / 2025-09-17
Note that the v0.4.0 and v0.4.1 releases are functionally identical.
Added
- Introduce
max_connection_poolsdatabase 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::RootConfigtoBaseConfig. @flavorjones - Rails dependency bumped to
>= 8.1.beta#172 @andrewmarkle
0.3.0
0.3.0 / 2025-09-09
Improved
#inspecton instances of tenanted models includes the tenant. #155 @miguelmarcondesf @flavorjonesTenantSelectormiddleware no longer directly renders a 404. Instead, it configures ActionDispatch::ShowExceptions middlware and raises an appropriate exception. #167 @flavorjones