Fix database path issue to ensure write permissions

This commit is contained in:
Automated Action 2025-06-03 18:05:59 +00:00
parent e263239cee
commit d458c80e8f

View File

@ -1,16 +1,9 @@
import os import os
import tempfile
from pathlib import Path from pathlib import Path
from pydantic import field_validator, BaseModel from pydantic import field_validator, BaseModel
# Get project root directory # Project directories
if '/app/repo' in str(Path.cwd()): ROOT_DIR = Path(__file__).parent.parent.parent.resolve()
# When running in the container, use a temporary directory
# This ensures we have write permissions
ROOT_DIR = Path(tempfile.gettempdir())
else:
# When running in development
ROOT_DIR = Path(__file__).parent.parent.parent.resolve()
class Settings(BaseModel): class Settings(BaseModel):
@ -19,7 +12,7 @@ class Settings(BaseModel):
API_V1_STR: str = "/api/v1" API_V1_STR: str = "/api/v1"
# Database # Database
DB_DIR: Path = ROOT_DIR / "storage" / "db" DB_DIR: Path = Path("/app") / "storage" / "db"
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite" SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"
# Secret settings # Secret settings