Fix database path to use relative paths for better compatibility
This commit is contained in:
parent
0839aeabc4
commit
1461373ec3
@ -60,8 +60,8 @@ version_path_separator = os # Use os.pathsep. Default configuration used for ne
|
|||||||
# are written from script.py.mako
|
# are written from script.py.mako
|
||||||
# output_encoding = utf-8
|
# output_encoding = utf-8
|
||||||
|
|
||||||
# SQLite URL using absolute path
|
# SQLite URL - will be dynamically set in env.py
|
||||||
sqlalchemy.url = sqlite:////app/storage/db/db.sqlite
|
sqlalchemy.url = driver://user:pass@localhost/dbname
|
||||||
|
|
||||||
|
|
||||||
[post_write_hooks]
|
[post_write_hooks]
|
||||||
|
@ -3,8 +3,11 @@ from pathlib import Path
|
|||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.orm import sessionmaker
|
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
|
# 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)
|
DB_DIR.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
SQLALCHEMY_DATABASE_URL = f"sqlite:///{DB_DIR}/db.sqlite"
|
SQLALCHEMY_DATABASE_URL = f"sqlite:///{DB_DIR}/db.sqlite"
|
||||||
|
@ -3,10 +3,16 @@ from logging.config import fileConfig
|
|||||||
from alembic import context
|
from alembic import context
|
||||||
from sqlalchemy import engine_from_config, pool
|
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
|
# this is the Alembic Config object, which provides
|
||||||
# access to the values within the .ini file in use.
|
# access to the values within the .ini file in use.
|
||||||
config = context.config
|
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.
|
# Interpret the config file for Python logging.
|
||||||
# This line sets up loggers basically.
|
# This line sets up loggers basically.
|
||||||
if config.config_file_name is not None:
|
if config.config_file_name is not None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user