1. Michael Bayer
  2. alembic

Issues

Issue #66 resolved

"alembic downgrade 2618d46ca35c --sql" does not work

delegans
created an issue

does not work: {{{ alembic downgrade 2618d46ca35c --sql ... AttributeError: 'NoneType' object has no attribute 'module' }}} but this is ok: {{{ alembic downgrade 2618d46ca35c }}}

Comments (13)

  1. delegans reporter

    Thanks for a quick response.

    Now when I downgrade with --sql option:

    alembic downgrade 2618d46ca35c --sql
    
    INFO  [alembic.migration] Context impl OracleImpl.
    INFO  [alembic.migration] Generating static SQL
    INFO  [alembic.migration] Will assume transactional DDL.
    SET TRANSACTION READ WRITE
    
    /
    
    Revision 2618d46ca35c is not an ancestor of base
    

    But downgrade without --sql option successfully done:

    INFO  [alembic.migration] Context impl OracleImpl.
    INFO  [alembic.migration] Will assume transactional DDL.
    INFO  [alembic.migration] Running downgrade 477a76ebfda8 -> 2618d46ca35c
    

    Is it bug?

  2. Michael Bayer repo owner

    "alembic upgrade|downgrade <n>" means, "upgrade or downgrade the database, starting at the current database's version and stepping to version <n>". --sql mode then augments this, "instead of connecting to the database, let *me* specify the starting version". It would be inconsistent for "alembic upgrade <n> --sql" to change the meaning of <n> to be "from current rev to <n>" to only mean "*only* rev <n>". Right now, "alembic upgrade <n> --sql" assumes *base* to be the starting rev.

    really, the only change I'd make here if any would be to not have "base" be implicit in the upgrade path. explicit is better than implicit. this confusion wouldn't be occurring.

  3. Robert Buchholz

    Agreed on the explicit path, but please make the error message more informative then. Something along the lines of "Always specify a revision to downgrade from". Downgrading from base never makes sense.

    Regarding the issue in particular: As --sql will create offline statements for review anyway, I think assuming a downgrade from head is sensible and consistent with assuming an upgrade from base.

  4. Log in to comment