feat: add ADMIN_DATABASE_URL setting with fallback to DATABASE_URL
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,20 @@ class Settings(BaseSettings):
|
||||
"""Get sync URL by removing asyncpg prefix from DATABASE_URL."""
|
||||
return self.DATABASE_URL.replace("postgresql+asyncpg://", "postgresql://", 1)
|
||||
|
||||
# Admin database — resolutionflow_admin role, BYPASSRLS.
|
||||
# Used by /admin/* endpoints. Defaults to DATABASE_URL for local dev.
|
||||
ADMIN_DATABASE_URL: str = ""
|
||||
|
||||
@field_validator("ADMIN_DATABASE_URL", mode="before")
|
||||
@classmethod
|
||||
def default_admin_database_url(cls, v: str, info) -> str:
|
||||
"""Fall back to DATABASE_URL if ADMIN_DATABASE_URL is not set."""
|
||||
if not v:
|
||||
return info.data.get("DATABASE_URL", "")
|
||||
if v.startswith("postgresql://"):
|
||||
return v.replace("postgresql://", "postgresql+asyncpg://", 1)
|
||||
return v
|
||||
|
||||
# JWT Settings
|
||||
SECRET_KEY: str = _DEFAULT_SECRET_KEY
|
||||
|
||||
|
||||
Reference in New Issue
Block a user