Alembic Can't Detect my Models #1749
Replies: 2 comments 1 reply
-
this means that that's a valid pattern though is not too common since there's usually not much reason for it, unless you have your models broken out into several |
Beta Was this translation helpful? Give feedback.
-
|
No, I didn't do like that. It's like: class Base(DeclarativeBase):
pass
class User(Base):
__tablename__ = "users"
id: Mapped[int] = mapped_column(Integer, primary_key=True)
name: Mapped[str] = mapped_column(String(32))Just like that |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
I am using alembic with fastapi. In my project, I have 3 initial DB models: User, Item and OtherItem.
I tried everything, but alembic can't detect any of the models. I tried debugging, rewriting and everything i could find online including official docs. But no fix. After 5 straight hours of frustrations, just before I giving up, I tried to replace
Base.metadatawithUser.metadataafter importing the models intoenv.py, then bingooo, it works. But this seems not right because I couldn't find any explanation like that. Even when i told someone, he said I have to use Base not User. So, I think this is a bug, because my head hurts due to this hours of mental pain.Expected behavior
According to docs, I expected
Base.metadatato work without any issue. And my models to be detected automatically.Beta Was this translation helpful? Give feedback.
All reactions