3131from piccolo .utils .warnings import colored_warning
3232
3333if t .TYPE_CHECKING : # pragma: no cover
34- from piccolo .table import Table
3534 from piccolo .columns .column_types import ForeignKey
35+ from piccolo .query .methods .create_index import IndexMethod
36+ from piccolo .table import Table
3637
3738
3839class OnDelete (str , Enum ):
@@ -119,7 +120,7 @@ class ColumnMeta:
119120 primary : bool = False
120121 key : bool = False
121122 unique : bool = False
122- index : bool = False
123+ index : t . Union [ IndexMethod , bool ] = False
123124 required : bool = False
124125
125126 # Used for representing the table in migrations and the playground.
@@ -231,8 +232,10 @@ class Column(Selectable):
231232 If set, a unique contraint will be added to the column.
232233
233234 :param index:
234- If set, the an index is created for the column, which can improve
235- the speed of selects, but can slow down inserts.
235+ Whether an index is created for the column, which can improve
236+ the speed of selects, but can slow down inserts. If set to True, the
237+ default index type is created (b-tree). If False, no index is created.
238+ If an IndexMethod value is provided, that type of index is created.
236239
237240 :param required:
238241 This isn't used by the database - it's to indicate to other tools that
@@ -249,7 +252,7 @@ def __init__(
249252 primary : bool = False ,
250253 key : bool = False ,
251254 unique : bool = False ,
252- index : bool = False ,
255+ index : t . Union [ IndexMethod , bool ] = False ,
253256 required : bool = False ,
254257 ** kwargs ,
255258 ) -> None :
0 commit comments