def copy_column_constraints(func):
 def _column_cp(self, table_name, column_old, column_new, *args, **opts):
  try:
   constraint = self._find_foreign_constraints(table_name, column_old)[0]
   refs = self._lookup_constraint_references(table_name, constraint)
   if (refs is not None):
    (ftable, fcolumn) = refs
    if (ftable and fcolumn):
     fk_sql = self.foreign_key_sql(table_name, column_new, ftable, fcolumn)
     get_logger().debug(('Foreign key SQL: ' + fk_sql))
     self.add_deferred_sql(fk_sql)
  except IndexError:
   pass
  except DryRunError:
   pass
  try:
   reverse = self._lookup_reverse_constraint(table_name, column_old)
   for (cname, rtable, rcolumn) in reverse:
    fk_sql = self.foreign_key_sql(rtable, rcolumn, table_name, column_new)
    self.add_deferred_sql(fk_sql)
  except DryRunError:
   pass
  return func(self, table_name, column_old, column_new, *args, **opts)
 return _column_cp

def copy_column_constraints ( func ) : def _column_cp ( self , table_name , column_old , column_new , * args , ** opts ) : try : constraint = self . _find_foreign_constraints ( table_name , column_old ) [ 0 ] refs = self . _lookup_constraint_references ( table_name , constraint ) if ( refs is not None ) : ( ftable , fcolumn ) = refs if ( ftable and fcolumn ) : fk_sql = self . foreign_key_sql ( table_name , column_new , ftable , fcolumn ) get_logger ( ) . debug ( ( 'Foreign key SQL: ' + fk_sql ) ) self . add_deferred_sql ( fk_sql ) except IndexError : pass except DryRunError : pass try : reverse = self . _lookup_reverse_constraint ( table_name , column_old ) for ( cname , rtable , rcolumn ) in reverse : fk_sql = self . foreign_key_sql ( rtable , rcolumn , table_name , column_new ) self . add_deferred_sql ( fk_sql ) except DryRunError : pass return func ( self , table_name , column_old , column_new , * args , ** opts ) return _column_cp
decorates column operation functions for mysql .