Fix database path configuration for container environment
This commit is contained in:
parent
11ef92d44e
commit
3b82051f44
@ -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
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user