Running migrations programmatically for automated tests
261 views
Skip to first unread message
Diogo Baeder
unread,
Feb 9, 2015, 4:16:46 PM2/9/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sqlalchem...@googlegroups.com
Hi guys,
I'm trying to run database migrations programmatically, inside a setUpClass() method, sharing a preconfigured connection, but the migration execution gets stuck at the "alembic_version" table creation (somehow the cursor just gets stuck at this point, not sure why). It's important that I can run the migrations at this point, since I do a rollback at tearDownClass() to throw away any database changes.
Is there any tutorial or recipe for how to use alembic programmatically this way?
Thanks,
Diogo
Michael Bayer
unread,
Feb 9, 2015, 4:28:40 PM2/9/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
that includes sharing the connection and running command.upgrade.
cursors getting stuck usually happens when tables are being dropped, because they are locked. this is more unusual on the setup, but you’d need to see if the cursor is attempting to execute a statement against a resource that is locked by another connection (often a previous test that didn’t tear down).
> --
> 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.
Diogo Baeder
unread,
Feb 9, 2015, 9:52:23 PM2/9/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sqlalchem...@googlegroups.com
Thanks, I didn't notice that I had to run it through alembic.command. After I worked a bit more on it, it worked. :-)