I have an alembic migration script and I want to add some exception 
handling but not sure what is the best practice.

Basically, I have several issues to handle:

   1. A change was already made and not needed (e.g. if I try to 
   add_column, and this column already exists, I want it to continue)
   2. A table is locked (if I try to perform some operation on a table and 
   it is locked, I want to raise an exception)
   3. 
   
   other exceptions?
   
   def upgrade():
       engine = op.get_bind().engine
       op.add_column('t_break_employee', sa.Column('auto', sa.Boolean()))
       op.add_column('t_employee', sa.Column('settings', sa.Text()))
   
   
I thought about adding a class to be used with the 'with' statement on 
every change. Does it sound reasonable?

for example:

    def upgrade():
        engine = op.get_bind().engine
        with my_test():
            op.add_column('t_break_employee', sa.Column('auto', sa.Boolean()))
        with my_test():
            op.add_column('t_employee', sa.Column('settings', sa.Text()))

In that case, what are the exceptions I need to handle and how do I know if 
a table is locked?

-- 
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.

Reply via email to