'Gets the names of the constraints affecting the given columns.
If columns is None, returns all constraints of the type on the table.'

def _constraints_affecting_columns(self, table_name, columns, type='UNIQUE'):

    if self.dry_run:
        raise DryRunError('Cannot    get    constraints    for    columns.')
    if (columns is not None):
        columns = set(map((lambda s: s.lower()), columns))
    db_name = self._get_setting('NAME')
    cnames = {}
    for (col, constraints) in self.lookup_constraint(db_name, table_name):
        for (kind, cname) in constraints:
            if (kind == type):
                cnames.setdefault(cname, set())
                cnames[cname].add(col.lower())
    for (cname, cols) in cnames.items():
        if ((cols == columns) or (columns is None)):
            (yield cname)
