-
Notifications
You must be signed in to change notification settings - Fork 178
Apartment 4.0.0.alpha1: Complete architectural refactor with comprehensive spec coverage #327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Conversation
…iews, and add cspell configuration
- Add 13 new spec files covering all major components - Achieve comprehensive test coverage across PostgreSQL, MySQL, and SQLite - Add extensive documentation (CLAUDE.md files) for architecture context - Update docs/4.0-Upgrade.md with detailed migration guide for breaking changes - Fix Rails 8 compatibility issues in connection pooling - Add stress testing for high-concurrency tenant switching scenarios - Include database-agnostic tests for cross-platform compatibility - Add comprehensive error handling and edge case testing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Keep 4.0.0.alpha1 dependency requirements (Rails 7.1+, Ruby 3.2+) - Incorporate updated public_suffix constraint from development (< 7) - Maintain new dependencies needed for architecture (concurrent-ruby, zeitwerk) - Preserve enhanced metadata and file listing approach 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Remove .github/workflows/close-stale-issues.yml (no longer needed) - Update .github/workflows/gem-publish.yml to use actions/checkout@v5 (latest version) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
|
Nice to see, that things keep moving on! Thank you for your work! Still one question, which comes into my mind regarding connections per tenant: Am I right that this breaks transactions involving more that on tenant? E. g. we use delayed_job as active job backend because we can store jobs transactionally with the rest of the changes in the untenanted database. It doesn't make sense to have delayed_job workers for each tenant. I don't see the excluded_models in the code anymore. |
|
great question @henkesn! so I need to work on the documentation to show that instead of excluded_models, now in each model you can have a "pinned_tenant" so that your jobs model could be pinned to the public schema lib/apartment/concerns/model.rb But I hadn't thoroughly thought about the implication for a transaction that is trying to make changes to multiple schemas at the same time. Does that really work with Apartment 3.x? I guess it would if each SQL statement is processed sequentially, including the |
|
Thank you for your quick response, @mnovelo! The pinning feature sounds good! We are using a cluster MySQL DBMS and indeed MySQL supports cross database transactions. Should be the same for Postgres schemas. If I remember correctly, Apartment 3.x prefixes the database name to tables for DML queries. |
|
wow, great news! very much looking forward to it as we currently cannot use separate postgres databases because of non-thread safety (sidekiq does not switch connection properly) which affects overall architecture of our product. Once this is released we will be able to optimise structure and decrease number of servers we're using. |
Summary
This PR represents the Apartment 4.0.0.alpha1 release with a complete architectural refactor focused on connection-pool-per-tenant design. This is a major milestone that introduces significant performance improvements, enhanced thread safety, and comprehensive test coverage.
Key Architectural Changes
ActiveSupport::CurrentAttributesComprehensive Test Coverage
Added 13 new spec files with extensive coverage:
Breaking Changes (4.0.0.alpha1)
Configuration Changes:
tenant_names→tenants_provider(must be callable)tenant_strategysetting (:schema,:database_name,:shard,:database_config)API Changes:
Apartment::Tenant.current_tenant→Apartment::Tenant.currentApartment::Tenant.reset!→Apartment::Tenant.resetMiddleware Updates:
ensureblocksPerformance Improvements
Documentation & Migration Support
docs/4.0-Upgrade.mdwith step-by-step migrationTest Coverage Verification
Cross-Database Testing ✅
Verified compatibility across all database engines:
Stress Testing ✅
Rails Version Compatibility ✅
Tested across multiple Rails versions:
Test Plan
Migration Timeline
Recommended: 1-2 sprint cycles for complete migration and testing
This alpha release provides a stable foundation for early adopters to begin migration while we gather feedback for the final 4.0.0 release.
🤖 Generated with Claude Code