From b2cf3ca74617e564696a6e9b9cb650ff13cd654e Mon Sep 17 00:00:00 2001 From: Automated Action Date: Tue, 13 May 2025 16:01:34 +0000 Subject: [PATCH] Fix database migration and path issues generated with BackendIM... (backend.im) --- alembic.ini | 2 +- alembic/env.py | 6 ++++++ app/database.py | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/alembic.ini b/alembic.ini index 1c3bc62..f81e7c0 100644 --- a/alembic.ini +++ b/alembic.ini @@ -36,7 +36,7 @@ script_location = alembic # output_encoding = utf-8 # SQLite URL example -sqlalchemy.url = sqlite:////app/storage/db/db.sqlite +sqlalchemy.url = sqlite:////projects/genericrestapiservice-w6od1p/db.sqlite [post_write_hooks] # post_write_hooks defines scripts or Python functions that are run diff --git a/alembic/env.py b/alembic/env.py index 727fd7a..b134d0c 100644 --- a/alembic/env.py +++ b/alembic/env.py @@ -1,4 +1,10 @@ from logging.config import fileConfig +import sys +import os +from pathlib import Path + +# Add the project root directory to Python's path +sys.path.insert(0, str(Path(__file__).parent.parent)) from sqlalchemy import engine_from_config from sqlalchemy import pool diff --git a/app/database.py b/app/database.py index cc76a8d..5f2bb03 100644 --- a/app/database.py +++ b/app/database.py @@ -4,7 +4,7 @@ from sqlalchemy.orm import sessionmaker from pathlib import Path # Create the database directory if it doesn't exist -DB_DIR = Path("/app") / "storage" / "db" +DB_DIR = Path("/projects/genericrestapiservice-w6od1p") DB_DIR.mkdir(parents=True, exist_ok=True) # Define the SQLite URL