Alembic autogenerate wants to remove foreign key indexes #598
Replies: 3 comments
|
the same problem occurs with field that has a unique index: class User(SQLModel, table=True):
id: Optional[int] = Field(default=None, primary_key=True)
username: str = Field(unique=True)
i.e. |
0 replies
|
the db is SQLite in case that matters |
0 replies
|
Ok, found the reason for this:
so the fix for me was to add |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
First Check
Commit to Help
Example Code
Description
I initially created my db using
SQLModel.metadata.create_all(engine)This added a foreign key index on the above table
gamesession_user_idas you would expectNow I am adding Alembic migrations to my project
In my alembic
env.pyI have imported my models and given the SQLModel metadata:when I run
alembic checkoralembic revision --autogenerateI get:and for the latter the generated revision drops the index
So it seems like Alembic doesn't understand the foreign keys on SQLModel models properly
Operating System
macOS
Operating System Details
No response
SQLModel Version
0.0.8
Python Version
Python 3.11.1
Additional Context
No response
All reactions