Fix database path to use relative paths for better compatibility

This commit is contained in:
Automated Action 2025-05-31 13:35:59 +00:00
parent 0839aeabc4
commit 1461373ec3
3 changed files with 12 additions and 3 deletions

View File

@ -60,8 +60,8 @@ version_path_separator = os # Use os.pathsep. Default configuration used for ne
# are written from script.py.mako
# output_encoding = utf-8
# SQLite URL using absolute path
sqlalchemy.url = sqlite:////app/storage/db/db.sqlite
# SQLite URL - will be dynamically set in env.py
sqlalchemy.url = driver://user:pass@localhost/dbname
[post_write_hooks]

View File

@ -3,8 +3,11 @@ from pathlib import Path
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
# Get the project root directory
PROJECT_ROOT = Path(__file__).parent.parent.parent.absolute()
# Create the directory for the SQLite database if it doesn't exist
DB_DIR = Path("/app") / "storage" / "db"
DB_DIR = PROJECT_ROOT / "app" / "storage" / "db"
DB_DIR.mkdir(parents=True, exist_ok=True)
SQLALCHEMY_DATABASE_URL = f"sqlite:///{DB_DIR}/db.sqlite"

View File

@ -3,10 +3,16 @@ from logging.config import fileConfig
from alembic import context
from sqlalchemy import engine_from_config, pool
# Import db settings
from app.db.session import SQLALCHEMY_DATABASE_URL
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Set the SQLAlchemy URL in the alembic config
config.set_main_option("sqlalchemy.url", SQLALCHEMY_DATABASE_URL)
# Interpret the config file for Python logging.
# This line sets up loggers basically.
if config.config_file_name is not None: