Guidance requested: integrated Alembic migration CLI dependencies #2062
Replies: 4 comments
Architectural & Packaging GuidanceTo give you a clear direction before reopening the PR, here is how Tiangolo's ecosystem (FastAPI, SQLModel, Typer) typically resolves this dilemma, along with why your PR was automatically closed: 1. Which Packaging Direction?❌ Direction 1: Core Runtime Dependencies (Not Recommended)Making
💡 Direction 2: Optional Dependency Extra (
|
|
I think option 2, an optional dependency extra, would be a reasonable approach. Alembic is useful for production SQLModel applications, but it isn't required by SQLModel itself. SQLModel can be used without migrations, so making Alembic and Typer core dependencies would add packages to every SQLModel installation, including users who don't use the migration CLI. An optional extra would keep the base installation lightweight while still providing a first-party workflow, for example: pip install "sqlmodel[migrations]"
or the equivalent with `uv`.
I also think this fits reasonably well with the current documentation. The SQLModel docs describe migrations as something that is generally useful for production applications, rather than as a requirement for using SQLModel.
One thing I would clarify before implementing the CLI is whether the goal is to provide a stable SQLModel-specific migration abstraction, or mainly a convenient wrapper around Alembic. If it is primarily a wrapper around Alembic, keeping it behind an optional dependency seems like the least invasive approach. |
|
Thanks @amasen02 and @vansh070605 for the guidance. I've reworked the implementation to follow the optional-extra direction (option 2):
On the design question @vansh070605 raised: the CLI is intentionally a thin, typed wrapper around One blocker I want to surface: the auto-close bot rejects any change to Could a maintainer confirm whether the optional-extra approach is acceptable, and if so help land the |
|
The thin wrapper approach around alembic.command with guarded imports makes complete sense here. To get around the bot auto-closing on pyproject.toml changes, a common workaround is to open a PR containing only the code and tests (making sure CLI tests gracefully skip or mock if the dependencies aren't present in CI), leaving pyproject.toml unmodified. You can provide the required [project.optional-dependencies] diff directly in the PR description for the maintainer to commit upon merge. This gets the actual implementation reviewed without triggering the supply-chain security bot. |
Uh oh!
There was an error while loading. Please reload this page.
Hi maintainers,
I revived the work from #689 against current
mainin #2061. The implementation adds asqlmodel migrationsCLI with Alembic commands and documentation. The test matrix passed, but #2061 was closed automatically because it modifiespyproject.tomlanduv.lock.The feature needs Alembic and Typer available at runtime for the console command. Before proposing it again, could you advise which packaging direction you prefer?
The updated implementation preserves the current PDM/uv setup and current CI, and replaces the original deprecated entry-point loader with
importlib.metadata. I am happy to adapt the PR to the preferred design.Thanks!
All reactions