diff --git a/migrations/env.py b/migrations/env.py index f211e85..4029223 100644 --- a/migrations/env.py +++ b/migrations/env.py @@ -1,9 +1,16 @@ +import os +import sys from logging.config import fileConfig -from sqlalchemy import engine_from_config -from sqlalchemy import pool +# Add the project root directory to the Python path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from alembic import context +from sqlalchemy import engine_from_config, pool + +# We need to import models so they're registered with SQLAlchemy +import app.models.todo # noqa +from app.db.database import Base # this is the Alembic Config object, which provides # access to the values within the .ini file in use. @@ -15,8 +22,6 @@ fileConfig(config.config_file_name) # add your model's MetaData object here # for 'autogenerate' support -from app.models.todo import Todo -from app.db.database import Base target_metadata = Base.metadata # other values from the config, defined by the needs of env.py,