feat(api): enhance database migration locking mechanism and configuration

- Introduced a configurable Redis lock TTL for database migrations in DeploymentConfig.
- Updated the upgrade_db command to handle lock release errors gracefully.
- Added documentation for the new MIGRATION_LOCK_TTL environment variable in the .env.example file and docker-compose.yaml.

(cherry picked from commit 4a05fb120622908bc109a3715686706aab3d3b59)
This commit is contained in:
L1nSn0w
2026-02-13 12:15:55 +08:00
parent 1977e68b2d
commit 9acdfbde2f
5 changed files with 104 additions and 3 deletions

View File

@ -1,4 +1,4 @@
from pydantic import Field
from pydantic import Field, PositiveInt
from pydantic_settings import BaseSettings
@ -32,3 +32,8 @@ class DeploymentConfig(BaseSettings):
description="Deployment environment (e.g., 'PRODUCTION', 'DEVELOPMENT'), default to PRODUCTION",
default="PRODUCTION",
)
MIGRATION_LOCK_TTL: PositiveInt = Field(
description="Redis lock TTL for startup DB migration (seconds). Increase for large/slow databases.",
default=3600,
)