Skip to content

Add optional Alembic migration CLI (sqlmodel[migrations]) - #2094

Closed
vmskonakanchi wants to merge 16 commits into
fastapi:mainfrom
vmskonakanchi:resolve-pr-689
Closed

vmskonakanchi wants to merge 16 commits into
fastapi:mainfrom
vmskonakanchi:resolve-pr-689

Conversation

@vmskonakanchi

Copy link
Copy Markdown

Summary

This carries forward the Alembic migration CLI from #689 against current main, with the packaging concerns from #2062 resolved. It supersedes #2061, which was auto-closed for modifying dependency files.

It adds an optional sqlmodel migrations CLI (thin, typed wrappers around alembic.command, exposed via Typer) plus documentation, and lays the groundwork for an extensible sqlmodel CLI via entry points.

Packaging changes (addressing why #2061 was closed)

Following the guidance in discussion #2062:

  • Optional extra instead of core dependencies. alembic and typer are now under [project.optional-dependencies] as a migrations extra, so the base sqlmodel install stays lightweight. Users opt in with pip install "sqlmodel[migrations]".
  • No lockfile changes. uv.lock is unchanged in this PR; it can be regenerated by the maintainers' release workflow on merge.
  • Guarded imports. If the extra is not installed, the CLI raises a friendly message telling the user to install sqlmodel[migrations] rather than a raw ModuleNotFoundError.

CLI structure

sqlmodel
└── migrations
    ├── init
    ├── revision
    ├── show
    ├── merge
    ├── upgrade
    └── downgrade

Docs

  • Adds an advanced migrations guide with an Installation section covering the migrations extra.

Validation

  • uv run pytest tests/test_cli — passes (6 tests)
  • uv run ruff check sqlmodel/cli tests/test_cli — passes
  • uv run sqlmodel migrations --help — lists all commands
  • Verified the guarded import shows the friendly install message when typer is unavailable

Context

Happy to adapt the design (e.g. wrapper vs. abstraction scope) based on maintainer preference.

@github-actions

Copy link
Copy Markdown
Contributor

This PR modifies dependency files (pyproject.toml or uv.lock), which is restricted to members of the fastapi organization on GitHub.

If you need a dependency change, please open a discussion describing what you need and why.

Closing this PR automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants