-
-
Notifications
You must be signed in to change notification settings - Fork 667
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
Alembic integration and documentation #689
base: main
Are you sure you want to change the base?
Conversation
📝 Docs preview for commit 32afa19 at: https://50871b3d.sqlmodel.pages.dev |
📝 Docs preview for commit 449882e at: https://f87a6f0c.sqlmodel.pages.dev |
📝 Docs preview for commit 0083a16 at: https://0f49201d.sqlmodel.pages.dev |
📝 Docs preview for commit b5944f0 at: https://e4e3fa97.sqlmodel.pages.dev |
📝 Docs preview for commit cc42afb at: https://c12e3a89.sqlmodel.pages.dev |
📝 Docs preview for commit 1eb82af at: https://ebd5efa7.sqlmodel.pages.dev |
Todo:
One missing piece is around testing Alembic it self. Looking forward: I am planning support some method called inside templates' Main idea is to get the model from the config's I'd like some community feedback on such an idea. |
Seems like great work with the template and docs to me. We've used the Alembic CLI for using Alembic with SQLModel, what benefits does this CLI offer? I'm not sure if it's useful to wrap Alembic to own CLI if it just passes on the calls to be done the same way as the upstream Alembic CLI does. But I did not read carefully what happens there, maybe it's helpful. |
Hey @antont, At the moment not that much TBH 😅
|
sqlalchemy2-stubs = {version = "*", allow-prereleases = true} | ||
sqlalchemy2-stubs = { version = "*", allow-prereleases = true } | ||
typer = "^0.9.0" | ||
alembic = "^1.12.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that adding a dependency needs a formal discussion.
On one hand, alembic
is pretty lean, seems to only depend on sqlalchemy
which this package already depends on too.
On the other, there are bound to be users that don't generate or apply migrations, rather consume some existing database instead. These users get a bit of bloat, and possibly a restriction on sqlalchemy versions they can use in their application.
This specific library addition may have been carefully thought through and may be OK.
A random library addition would be a problem.
Thus, I'd love to see a discussion and maintainer vote/rationale.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I mentioned above, we used alembic happily with sqlmodel, so maybe it's better indeed for sqlmodel to not depend on it, but just have things so that alembic can be used for it .. like it already can be.
Tiangolo does have this in the roadmap there so maybe he also has ideas for a tighter integration. I guess it could be also in an extra package, like sqlmodel-migrations, to avoid a runtime dep.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it should be a separate package, just like alembic is separated from sqlalchemy. That would also allow this to be released more easily and have people play with it, test it. Have you thought about releasing it @Jufik ?
Hey! |
@tiangolo documentation in the advanced docs on migrations as well as the incorporation of something like this would be incredibly useful |
Hi @tiangolo is there an update on when this can be merged? 🙏 thank you so much for your work! ✨ |
This is an to integrates Alembic within SqlModel (mentioned in #654)
Implementation is pretty straight forward and lays fundation to provide an extendible
sqlmodel
CLI throughsqlmodel
entrypoints. (though about Pluggy be felt like an overkill).Current CLI structure is:
Command are typed wrappers for the original
alembic.command
functions, exposed through Typer.Usage and Documentation can be found in the advanced section.
More that glad to get any feedback or suggestions for improvements!