On Wed, Feb 21, 2018 at 1:18 AM, <jens.troe...@gmail.com> wrote: > Hello, > > Is there a supported way to get programmatic access to the history of an > Alembic migration chain? I mean, the command > >> alembic -c foo.ini history > 3bf9af8da72c -> cb13f97d30c6 (head), Table funk > 33b960335847 -> 3bf9af8da72c, Column funk > … > 36afb00c3a4 -> 7dd0eef31115, Funky funk > <base> -> 36afb00c3a4, Getting started > > …tells me the history. Is there access to that history through the `alembic` > module in Python?
you can take a look at the source of alembic.command to get the general idea, as well as docs like http://alembic.zzzcomputing.com/en/latest/api/script.html?highlight=scriptdirectory#alembic.script.ScriptDirectory , http://alembic.zzzcomputing.com/en/latest/api/script.html?highlight=walk_revisions#alembic.script.ScriptDirectory.walk_revisions : from alembic.script import ScriptDirectory from alembic.config import Config config = Config("/path/to/yourapp/alembic.ini") script = ScriptDirectory.from_config(config) for sc in script.walk_revisions( base="base", head="heads"): # built in printer, or just look at each "sc" object config.print_stdout( sc.cmd_format( verbose=True, include_branches=True, include_doc=True, include_parents=True)) or the commands themselves can be called directly (I'm pasting from http://alembic.zzzcomputing.com/en/latest/api/commands.html?commands): from alembic.config import Config from alembic import command alembic_cfg = Config("/path/to/yourapp/alembic.ini") command.history(alembic_cfg) > > Thanks! > Jens > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy-alembic" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlalchemy-alembic+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alembic+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.