Fix Alembic migration import error and database path issues

This commit is contained in:
Automated Action 2025-05-16 15:01:25 +00:00
parent e0517031bd
commit 06dafd5b0c
3 changed files with 9 additions and 2 deletions

View File

@ -36,7 +36,7 @@ script_location = migrations
# output_encoding = utf-8
# SQLite URL example
sqlalchemy.url = sqlite:////app/storage/db/db.sqlite
sqlalchemy.url = sqlite:///%(here)s/storage/db/db.sqlite
[post_write_hooks]
# post_write_hooks defines scripts or Python functions that are run

View File

@ -21,7 +21,9 @@ class Settings(BaseSettings):
raise ValueError(v)
# Database
DB_DIR: Path = Path("/app") / "storage" / "db"
# Get the project root directory dynamically
BASE_DIR: Path = Path(__file__).parent.parent.parent.absolute()
DB_DIR: Path = BASE_DIR / "storage" / "db"
class Config:
case_sensitive = True

View File

@ -1,4 +1,9 @@
from logging.config import fileConfig
import sys
from pathlib import Path
# Add the project root directory to the Python path
sys.path.insert(0, str(Path(__file__).parent.parent.absolute()))
from sqlalchemy import engine_from_config
from sqlalchemy import pool