[Feature] Support for customizing saga storage table names through environment variables #44
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Release Notes - python-cqrs 4.6.4
Summary
This release adds support for customizing saga storage table names through environment variables, providing better flexibility for multi-tenant deployments and service-specific naming conventions.
Added
Saga Storage Configuration
Environment Variable Support for Saga Table Names: Added support for customizing saga execution and log table names via environment variables, similar to the existing outbox table configuration.
CQRS_SAGA_EXECUTION_TABLE_NAME: Environment variable to customize the saga execution table name (default:"saga_executions")CQRS_SAGA_LOG_TABLE_NAME: Environment variable to customize the saga log table name (default:"saga_logs")This enhancement allows different services or deployments to use service-specific table names (e.g.,
service_manager_saga_executions,payment_service_saga_executions) while maintaining the same codebase.Usage:
The table names are automatically loaded from environment variables when the
cqrs.saga.storage.sqlalchemymodule is imported, usingpython-dotenvfor.envfile support.Technical Details
Changes in
cqrs.saga.storage.sqlalchemyosanddotenvimportsdotenv.load_dotenv()call to load environment variables from.envfilesDEFAULT_SAGA_EXECUTION_TABLE_NAMEandDEFAULT_SAGA_LOG_TABLE_NAMEto be read from environment variables with fallback to default valuesSagaExecutionModelandSagaLogModelto use the configurable table namesForeignKeyreference inSagaLogModelto use the configurable execution table nameBackward Compatibility
saga_executionsandsaga_logs) are usedMigration Guide
For Existing Users
No migration required. The feature is backward compatible and uses default table names if environment variables are not set.
For New Users or Custom Table Names
Set environment variables in your
.envfile or deployment configuration:Ensure your database migration creates tables with the custom names:
The
SqlAlchemySagaStoragewill automatically use the custom table names when initialized.Examples
Example: Service-Specific Table Names
Related Issues