You should be able to use a savepoint around that operation to prevent
this issue from happening. This works for simple things like INSERTs
and hopefully works for DDL as well. Either with an ORM Session or with
the Connection, the begin_nested() method gives you a savepoint
transaction.
>
> To complicate matters, one of the possible DBs is SQLite so I have to do
> this via op.batch_etc. Thankfully that data is not essential so deleting
> the whole DB is an option there - not so much for the Postgres data.
For SQLite I've always been a proponent of dropping the whole thing and
recreating from scratch. The existence of batch mode is due to all the
pressure I get from users who don't want to do it that way, but I still
favor not trying to make SQLite do real migrations - its creators
disagree with this use case hence they've never implemented it.
>
> So my questions are:
>
> 1) How can I handle this drop_constraint call when we didn't specify a
> constraint name in the first place?
> 2) If the best way is for me to just attempt to drop constraints by
> name, trying several names, how can I catch or avoid the first error and
> try subsequent constraint names?
>
> Thanks,
> Ben
>
> --
> 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
> <mailto:
sqlalchemy-alem...@googlegroups.com>.
> For more options, visit
https://groups.google.com/d/optout.