Skip to content

Releases: bernardopires/django-tenant-schemas

2.0.0

26 Sep 15:39
ae7b2cd

Choose a tag to compare

Version 2.0.0 - Major Modernization Release

This major release modernizes django-tenant-schemas for current Django and Python versions while maintaining API backward compatibility. After 2+ years since v1.12.0, this release drops legacy version support and introduces significant infrastructure improvements.

🔥 Breaking Changes

  • Removed: Python 2.7, 3.6, 3.7
  • Removed: Django 1.11 through 4.1
  • Removed: six library (Python 2/3 compatibility)
  • Removed: psycopg2-binary as required dependency

Migration Path

Existing projects can upgrade seamlessly as the package maintains backward compatibility at the API level. Update your environment:

  1. Upgrade to Python 3.8+ and Django 4.2+
  2. Choose PostgreSQL client: pip install django-tenant-schemas[psycopg2] or django-tenant-schemas[psycopg]
  3. Update middleware configuration if using deprecated patterns
  4. Update storage settings for Django 5.x if applicable

🚀 Major Features & Improvements

#708 - PostgreSQL Client Flexibility

  • Dual PostgreSQL client support: Choose between psycopg2 or psycopg (psycopg3)
  • Optional dependencies: Install with [psycopg2] or [psycopg] extras
  • Automatic fallback logic: Seamless switching between PostgreSQL drivers
# Choose your PostgreSQL client
pip install django-tenant-schemas[psycopg2]  # Traditional psycopg2
pip install django-tenant-schemas[psycopg]   # Modern psycopg3

#707 - Modern Python Packaging

  • PEP 518 compliance: Migrated from setup.py to pyproject.toml
  • src-layout adoption: Modern package structure (src/tenant_schemas/)
  • GitHub Actions CI: Replaced Travis CI with modern workflow
  • uv integration: Faster dependency management and builds
  • Improved test matrix: Comprehensive testing across Python/Django combinations
  • Middleware modernization: Updated to current Django middleware patterns
  • Storage configuration: Support for Django 5.x STORAGES setting
  • Migration compatibility: Fixed Django 5.2 compatibility issues

🐛 Critical Bug Fixes

#710 - RecursionError with psycopg3 and DEBUG=True

Fixed a critical issue where using psycopg with DEBUG=True caused infinite recursion:

  • Root cause: Django's SQL debug logging triggered psycopg3's mogrify operation, creating fresh cursors that re-entered the _cursor() method
  • Solution: Added ContextVar guard to prevent recursion during search_path operations
  • Performance: Smart caching only sets search_path when tenant configuration changes
  • Compatibility: Works with both psycopg2 and psycopg

#712 - Django 4.2+ Introspection Support

Fixed NotImplementedError when running Django commands like flush:

  • Problem: Django 4.2+ requires get_sequences() method for database introspection
  • Solution: Implemented schema-aware sequence introspection using PostgreSQL system tables
  • Impact: Enables full Django 4.2+ command compatibility
  • Testing: Comprehensive test coverage prevents regression

🧹 Code Modernization

#709 - Python 3+ Syntax Modernization

  • Removed defensive imports for old Django/Python versions
  • Eliminated __future__ imports (not needed in Python 3.8+)
  • Updated documentation links from Django 1.8/1.11 to Django 4.2
  • Removed legacy compatibility code for Django < 1.7

Infrastructure Improvements

  • Removed deprecated middleware patterns
  • Modernized import organization
  • Updated test configurations
  • Improved error handling

📚 Documentation & Developer Experience

#711 - Enhanced Tutorial and Examples

  • Modern setup instructions: Updated for uv dependency management
  • Automated validation: GitHub Actions workflow validates tutorial functionality
  • New management command: create_client for easier tenant creation
  • Django compatibility: Updated settings and URL patterns
  • Clear migration path: Step-by-step upgrade guidance

Developer Tools

  • Comprehensive CI matrix: Tests all supported Python/Django combinations
  • Fast dependency management: uv integration for development
  • Modern packaging standards: PEP 518 compliance
  • Improved test coverage: Better isolation and parallel execution

📋 Complete Change Log

Pull Requests Included

  1. #707 - Modernize for current Django and Python versions
  2. #708 - Support both psycopg2 and psycopg PostgreSQL clients
  3. #709 - Remove code for old Django and Python versions
  4. #710 - Fix RecursionError with psycopg when DEBUG=True
  5. #711 - Fix tutorial and add automated validation
  6. #712 - Implement get_sequences() method for Django 4.2+ compatibility

🔮 Looking Forward

  • Django LTS Alignment: Supports current and future Django LTS releases
  • Modern Python: Takes advantage of Python 3.8+ features
  • Performance: Optimized for current PostgreSQL drivers
  • Maintainability: Clean, modern codebase easier to contribute to

💝 Acknowledgments

Special thanks to all contributors who made this release possible:

Support Django4

27 Aug 13:05
a77655c

Choose a tag to compare

Merge pull request #631 from timgates42/bugfix_typo_similar

docs: Fix simple typo, similiar -> similar

v1.9.0

03 Jun 11:58

Choose a tag to compare

Added custom tenant strategies by refactoring a BaseTenantMiddleware to allow greater control over the method used for determining the active tenant.

Parallel execution of database migrations using ParallelExecutor.

Added codes to check framework warnings and errors.

Documentation improvements and updating example projects and tutorials for recent versions of Django.