def create_index_query(self, model_class, field_name, unique):
        framing = 'CREATE %(unique)s INDEX %(index)s ON %(table)s(%(field)s);'

        if field_name not in model_class._meta.fields:
            raise AttributeError(
                'Field %s not on model %s' % (field_name, model_class)
            )

        field_obj = model_class._meta.fields[field_name]

        db_table = model_class._meta.db_table
        index_name = self.quote_name('%s_%s' % (db_table, field_obj.db_column))

        unique_expr = ternary(unique, 'UNIQUE', '')

        return framing % {
            'unique': unique_expr,
            'index': index_name,
            'table': self.quote_name(db_table),
            'field': self.quote_name(field_obj.db_column),
        }
dataset/ETHPy150Open kuri65536/python-for-android/sl4atools/fullscreenwrapper2/examples/calcount2_example/peewee.py/Database.create_index_query/original