'Alters the given column name so it will match the given field.
Note that conversion between the two by the database must be possible.
Will not automatically add _id by default; to have this behavour, pass
explicit_name=False.
@param table_name: The name of the table to add the column to
@param name: The name of the column to alter
@param field: The new field definition to use'

@invalidate_table_constraints
def alter_column(self, table_name, name, field, explicit_name=True, ignore_constraints=False):

    self._fix_field_definition(field)
    if (not ignore_constraints):
        qn = self.quote_name
        sch = qn(self._get_schema_name())
        tab = qn(table_name)
        table = '.'.join([sch, tab])
        try:
            self.delete_foreign_key(table_name, name)
        except ValueError:
            pass
        constraints = self._find_constraints_for_column(table_name, name, False)
        for constraint in constraints.keys():
            params = dict(table_name=table, constraint_name=qn(constraint))
            sql = (self.drop_constraint_string % params)
            self.execute(sql, [])
    ret_val = super(DatabaseOperations, self).alter_column(table_name, name, field, explicit_name, ignore_constraints=True)
    if (not ignore_constraints):
        for (cname, (ctype, args)) in constraints.items():
            params = dict(table=table, constraint=qn(cname))
            if (ctype == 'UNIQUE'):
                params['columns'] = ',    '.join(map(qn, args))
                sql = (self.create_unique_sql % params)
            elif (ctype == 'PRIMARY    KEY'):
                params['columns'] = ',    '.join(map(qn, args))
                sql = (self.create_primary_key_string % params)
            elif (ctype == 'FOREIGN    KEY'):
                continue
            elif (ctype == 'CHECK'):
                warn(ConstraintDropped(('CHECK    ' + args), table_name, name))
                continue
            else:
                raise NotImplementedError(("Don't    know    how    to    handle    constraints    of    type    " + type))
            self.execute(sql, [])
        if (field.rel and self.supports_foreign_keys):
            self.execute(self.foreign_key_sql(table_name, field.column, field.rel.to._meta.db_table, field.rel.to._meta.get_field(field.rel.field_name).column))
            model = self.mock_model('FakeModelForIndexCreation', table_name)
            for stmt in self._get_connection().creation.sql_indexes_for_field(model, field, no_style()):
                self.execute(stmt)
    return ret_val
