From 3b82051f442403b663db0e0aa1a24c84c9a794d2 Mon Sep 17 00:00:00 2001 From: Automated Action Date: Tue, 3 Jun 2025 12:24:02 +0000 Subject: [PATCH] Fix database path configuration for container environment --- alembic.ini | 4 ++-- app/db/session.py | 13 +++---------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/alembic.ini b/alembic.ini index c7365d0..fb0167e 100644 --- a/alembic.ini +++ b/alembic.ini @@ -36,8 +36,8 @@ script_location = migrations # output_encoding = utf-8 # SQLite URL example -# For container environment, use /app/repo/storage/db/db.sqlite -sqlalchemy.url = sqlite:////app/repo/storage/db/db.sqlite +# For container environment, use the proper path +sqlalchemy.url = sqlite:////projects/bloggingplatformapi-lncxqv/storage/db/db.sqlite [post_write_hooks] # post_write_hooks defines scripts or Python functions that are run diff --git a/app/db/session.py b/app/db/session.py index 6e1831c..216e12b 100644 --- a/app/db/session.py +++ b/app/db/session.py @@ -1,20 +1,13 @@ from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from pathlib import Path -import os -# Check if we're running in the container environment -IN_CONTAINER = os.path.exists('/app/repo') +# Get the project root directory +PROJECT_ROOT = Path("/projects/bloggingplatformapi-lncxqv") # Create the directory for the database if it doesn't exist -if IN_CONTAINER: - # Container path - DB_DIR = Path("/app") / "repo" / "storage" / "db" -else: - # Local development path - DB_DIR = Path("/app") / "storage" / "db" - +DB_DIR = PROJECT_ROOT / "storage" / "db" DB_DIR.mkdir(parents=True, exist_ok=True) SQLALCHEMY_DATABASE_URL = f"sqlite:///{DB_DIR}/db.sqlite"