-
-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to configure alembic autogenerate with multiple model files #1157
Comments
Have you try to import models to alembic env.py? |
Thank you, it worked when I import in env.py as
but not worked if I import
And honestly, I don't want to modify env.py everytime I add a new model. |
I think you just might need to sort out your imports, #somewhere at the beggining of env.py
from app1.models import *
from app2.models import *
import module_with_base and set |
Thank you but it doesn't work on my side :)) |
Create variable somewhere in project, for example:
Then just import app_models to env.py. When you create new models just add them to models.py app_models |
I am thinking of writing a util in my project to auto-discover the models.py in for example apps subdirectories and import them in the env.py dynamically. Do you think this can be the right way to handle this issue?
|
Describe the bug
Have a versions file that create
Account
. After add anotherProduct
model, Runalembic revision --autogenerate -m "..."
doesn't create new tableProduct
but drop current tableAccount
on new..py
inversions
To Reproduce
devops/db_migration/pg/env.py
devops/db_migration/pg/versions/d65c5dec925e_create_account_table.py
service/databases/__init__.py
service/databases/account.py
service/databases/product.py
...devops/db_migration $ alembic revision --autogenerate -m "create product table"
create new filedevops/db_migration/pg/versions/64ec73d106d7_create_product_table.py
Expected behavior
devops/db_migration/pg/versions/64ec73d106d7_create_product_table.py
should beVersions (please complete the following information):
ormar
version 0.12.2pydantic
version 1.10.8fastapi
version 0.99.1The text was updated successfully, but these errors were encountered: