Dry Run for alembic revision

1,843 views
Skip to first unread message

Daniel Son

unread,
Dec 2, 2014, 4:06:09 PM12/2/14
to sqlalchem...@googlegroups.com
Hi,

Is there a way to have a dry run for alembic revision?
Or a very easy way to detect an error case via the command. For example, I have 2 revisions that have just branched and now I need to create a merge point as the next revision.

I'm trying to create a build hook that catches this case and fails and alerts the developer to create a merge/fix parents before committing this set of revisions.

Thanks,
Daniel

Michael Bayer

unread,
Dec 2, 2014, 4:28:15 PM12/2/14
to sqlalchem...@googlegroups.com
if you’re just trying to catch issues at the level of the structure of revision files, the “history” command uses the same iteration that the “upgrade” command does. Just say “alembic history current:head” and it will either work or it won’t.

For a “dry” run where you can run SQL, usually —sql mode is the best approach. Alternatively if you have transactional DDL you can add a rollback() to your env.py to prohibit the transaction from being committed.

Daniel Son

unread,
Dec 2, 2014, 4:34:40 PM12/2/14
to sqlalchem...@googlegroups.com
alembic history -r current:head is perfect.
Thanks!


--
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-alem...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages