Search code examples
pythonflaskalembic

Alembic ignores new model and does not add new table to revision


How can I make alembic take a new file with a new model into account for a new revision? All the models are in the same directory /models but alembic seems to ignore it. How can it be included and tracked by alembic?


Solution

  • It should be imported one way or another when alembic runs, otherwise it won't know about it. You can for example create a models/__init__.py file and import your models there.

    Basically migrations/env.py needs to know about your models. You can import them there as well, but models init is probably easier.