def select_uuid_like_indexes_on_table(model, cursor):
    """
    Gets a list of database index names for the given model for the
    uuid-containing fields that have had a like-index created on them.

    :param model: Django model
    :param cursor: database connection cursor
    :return: list of database rows; the first field of each row is an index
        name
    """

    # VersionedForeignKey fields as well as the id fields have these useless
    # like indexes
    field_names = ["'%s'" % f.column for f in model._meta.fields if
                   isinstance(f, VersionedForeignKey)]
    field_names.append("'id'")
    sql = """
                select i.relname as index_name
                from pg_class t,
                     pg_class i,
                     pg_index ix,
                     pg_attribute a
                where t.oid = ix.indrelid
                  and i.oid = ix.indexrelid
                  and a.attrelid = t.oid
                  and a.attnum = ANY(ix.indkey)
                  and t.relkind = 'r'
                  and t.relname = '{0}'
                  and a.attname in ({1})
                  and i.relname like '%_like'
            """.format(model._meta.db_table, ','.join(field_names))
    cursor.execute(sql)
    return cursor.fetchall()
Gets a list of database index names for the given model for the
    uuid-containing fields that have had a like-index created on them.

    :param model: Django model
    :param cursor: database connection cursor
    :return: list of database rows; the first field of each row is an index
        name