Automated Schema Creation for Tenant Databases
This release adds automatic schema creation functionality for newly created tenant databases, significantly improving the setup process for new tenants.
🌟 New Features
- Automatic table creation in tenant databases
- Schema replication from main application
- Safe engine swapping mechanism
- Proper cleanup after schema creation
🔧 Technical Improvements
python
Before
CREATE DATABASE IF NOT EXISTS `{db_name}`;
Manual schema creation needed
After
CREATE DATABASE IF NOT EXISTS `{db_name}`;
Automatic schema creation:
self._db_instance.create_all() Tables automatically created
🛠️ Changes
- Added temporary engine swapping mechanism
- Implemented safe context management for database operations
- Added automatic table creation after database initialization
- Improved error handling during schema creation
🔒 Security
- Maintains proper isolation between tenant databases
- Preserves original database connections
- Safe handling of database credentials
🐛 Bug Fixes
- Fixed potential connection leaks during schema creation
- Ensured proper engine restoration after operations
📝 Usage Notes
No changes required to existing code. Schema creation is now automatic when creating new tenant databases.
🔍 Breaking Changes
None. This is a backward-compatible enhancement.
---
For Developers
If you need to customize the schema creation process, you can override the relevant methods in your implementation.
Migration Guide
Existing tenants are unaffected. New tenants will automatically receive the complete database schema.
---
For complete documentation, please refer to our [README.md](README.md)
**Full Changelog**: https://github.com/TaqsBlaze/tenori/compare/v1.1.1...v1.1.3