On 02/05/2016 12:46 PM, Jonathan Beluch wrote:
Hi, I have an existing pg database where I'd like to get the names in
order according to a new naming_convention. However, dropping and
recreating lots of indexes is obviously a bad idea.
I've coded RenameConstraintOp and RenameIndexOp along with the dispatch
functions. I'm trying to figure out the best way to hook into
autogenerate to output a rename instead of a create/drop.
Potential solutions?
* Rewriter doesn't seem like a good fit because it only takes in a
single operation and I want to remove two ops and add a different op.
the rewriter object, and more generally rewriting existing
autogenerations, is likely the best way to do this. you can do
rewriter for both addconstraint and dropconstraint, and have the
rewriter for dropconstraint just return an empty list. two rewriters
can coordinate using the context given. Or, write your own traversal
scheme for process_revision_directives.
* comparison function doesn't seem right either because it only adds
new operations, it doesn't override existing behavior
the existing comparison functions should be overridable, actually but
you'll still want to use most of them so you might have to tinker with
how things work a bit.
* traverse the entire migration structure pairwise and compare and
remove add/drop and insert rename
similar to rewriter, but you don't have to bend rewriter to work across
two different operations.
* fork and modify the alembic source
https://github.com/zzzeek/alembic/blob/master/alembic/autogenerate/compare.py#L526
for this one off migration
should not be necessary.
I'm leaning towards 4, since this will be a one time migration (now that
the naming_convention is in place). Please correct my understandings
above if I'm wrong. 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 [email protected]
<mailto:[email protected]>.
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 [email protected].
For more options, visit https://groups.google.com/d/optout.