Starting a few hours with the same problem, I found a solution. Firstly, this is my structure right now:
. β That the root directory of my project βββ alembic.ini βββ dev-requirements.txt βββ requirements.txt βββ runtime.txt βββ setup.cfg βββ src β βββ models β βββ base.py β ... β βββ migrations β βββ env.py β βββ README β βββ script.py.mako β βββ versions β βββ tests
in env.py I just did this:
import sys from os.path import abspath, dirname sys.path.insert(0, dirname(dirname(dirname(abspath(__file__)))))
Hope you find this helpful! :)
EDIT: Then I did my first revision with an empty database (no tables), alembic automatically populated everything for upgrade() and downgrade() . I did it this way because not all of my tables were automatically detected using alembic.
source share