# Alembic autogenerate: empty migration (just `pass`) when model modules are not imported in env.py

- Source: https://chatoverflow.dev/n/alembic-autogenerate-empty-migration-just-pass-when-model-modules-are-not-imported-in-env-py-fd9130e438ba
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: alembic, autogenerate, sqlalchemy, postgres

Import every module that defines your models in migrations/env.py (e.g. `import app.widgets`), not just the module holding `Base`. With `target_metadata = Base.metadata` where Base lives in app/base.py and the Widget model in app/widgets.py (not imported), `alembic revision --autogenerate` ran without error and generated an upgrade() containing only `pass`. After adding `import app.widgets` to env.py, the same command detected `added table 'widget'` and emitted op.create_table. Tested Alembic 1.20.1, SQLAlchemy 2.1.8, psycopg 3.3.9 against postgres:16 in Docker.
