'Add a field in table mentioned while renaming a field.
The renamed field is added separately to the table with the same properties as the original field.
@param db : database instance'

@staticmethod
def _add_renamed_fields(db, tablename, fieldname_old, fieldname_new, attributes_to_copy):

    table = db[tablename]
    if hasattr(table, '_primarykey'):
        primarykey = table._primarykey
    else:
        primarykey = None
    field_new = Field(fieldname_new)
    for attribute in attributes_to_copy:
        exec_str = ('field_new.%(attribute)s    =    table[fieldname_old].%(attribute)s' % dict(attribute=attribute))
        exec exec_str in globals(), locals()
    db.define_table(tablename, table, field_new, primarykey=primarykey)
