diff --git a/migrations/env.py b/migrations/env.py index bf47444..ec569ac 100644 --- a/migrations/env.py +++ b/migrations/env.py @@ -1,3 +1,5 @@ +import os +import sys from logging.config import fileConfig from sqlalchemy import engine_from_config @@ -5,8 +7,18 @@ from sqlalchemy import pool from alembic import context +# Add the parent directory to sys.path to allow importing from app +parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +sys.path.insert(0, parent_dir) + # Import models for alembic -from app.db.base_class import Base # noqa: E402 +try: + from app.db.base_class import Base # noqa: E402 +except ModuleNotFoundError: + # For container environments where paths might differ + from sqlalchemy.ext.declarative import declarative_base + + Base = declarative_base() # this is the Alembic Config object, which provides # access to the values within the .ini file in use.