sqlalchemy / sqlalchemy/alembic

add a classification to commands that they don't need a database, e.g. a third option to "online" / "offline" mode

Open
#617 10 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

migration environment use case
Dominant language
Python
Stars
4.4k
Forks
375
PR merge metrics
No merged PRs in 30d

Description

I am having an issue running alembic history. Because I have migrations which rely on modules within my project, I get a ModuleNotFoundError when running alembic history. I can work around this by setting the python path but I would rather the command was working "out of the box".

I tried setting revision_environment to true in the ini file, along with correcting the path in env.py. This results in an error caused by attempting to connect to the database, since the details required to connect are not available.

Is there an existing approach to being able to run alembic history with the revision environment but without the connection? If not would it make sense to alter the behaviour of history to load the environment in offline mode except where required (e..g when executed with --indicate_current)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the alembic history command and the env.py and ini configuration described in the issue; compare normal and offline execution, including --indicate_current. Determine how revision environments should load without a database connection, then verify that history works with project modules while connection-dependent behavior remains available.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sqlalchemy
Domain
cli, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.