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

When using --sql the current revision seems unknown #248

Closed
sqlalchemy-bot opened this Issue Nov 23, 2014 · 6 comments

Comments

Projects
None yet
1 participant
@sqlalchemy-bot

sqlalchemy-bot commented Nov 23, 2014

Migrated issue, originally created by xealot (@xealot)

Running this command:

$ alembic upgrade head

Alembic correctly starts from the revision which is set in the alembic_version table as expected. However after adding a --sql flag, Alembic no longer attempts to read the version from the DB and so the output is always from the beginning of all migrations.

$ alembic upgrade head --sql

Alternatively when I attempt to use --autogenerate with --sql in some cases I get the error "Database is not up to date". I assume this is because of the same or similar reason.

Am I missing something? Something that makes --sql behave the same as when not using --sql.

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Nov 23, 2014

Michael Bayer (@zzzeek) wrote:

  • The alembic revision command accepts the --sql option to
    suit some very obscure use case where the revision_environment
    flag is set up, so that env.py is run when alembic revision
    is run even though autogenerate isn't specified. As this flag is
    otherwise confusing, error messages are now raised if
    alembic revision is invoked with both --sql and
    --autogenerate or with --sql without
    revision_environment being set.
    fixes #248

15376ba

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Nov 23, 2014

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Nov 23, 2014

Michael Bayer (@zzzeek) wrote:

--autogenerate is an instruction that specifically requires that a database connection is present, so in the absense of very unique customizations to one's env.py, there's no reason you'd want to use --autogenerate with --sql and in fact there's never any reason to use --sql with alembic revision at all; this flag is allowed apparently as a means to help very specific env.py setups.

For upgrading/downgrading in --sql mode while being able to control the starting revision, please see
http://alembic.readthedocs.org/en/rel_0_6/tutorial.html#getting-the-start-version.

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Nov 23, 2014

xealot (@xealot) wrote:

Gah, sorry for the trouble. I was all over this section of the documentation and I thought I this pattern. I must have done something stupid because it does indeed work. Thanks again.

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Nov 23, 2014

Michael Bayer (@zzzeek) wrote:

the --sql flag accepted by alembic revision is completely screwy and I think i need that a long time ago for something, so thanks for bringing it up that its confusing!

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Nov 23, 2014

xealot (@xealot) wrote:

I didn't actually need the command but I too thought it didn't make sense so I thought I would see what happened. It felt like the same error to me so I mentioned it. My use case is definitely with the update/downgrade command.

@sqlalchemy-bot sqlalchemy-bot added the bug label Nov 27, 2018

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