2727from piccolo .columns .combination import Where
2828from piccolo .columns .defaults .base import Default
2929from piccolo .columns .reference import LazyTableReference
30+ from piccolo .columns .indexes import IndexMethod
3031from piccolo .querystring import QueryString
3132from piccolo .utils .warnings import colored_warning
3233
3334if t .TYPE_CHECKING : # pragma: no cover
3435 from piccolo .columns .column_types import ForeignKey
35- from piccolo .query .methods .create_index import IndexMethod
3636 from piccolo .table import Table
3737
3838
@@ -120,7 +120,8 @@ class ColumnMeta:
120120 primary : bool = False
121121 key : bool = False
122122 unique : bool = False
123- index : t .Union [IndexMethod , bool ] = False
123+ index : bool = False
124+ index_method : IndexMethod = IndexMethod .btree
124125 required : bool = False
125126
126127 # Used for representing the table in migrations and the playground.
@@ -233,9 +234,10 @@ class Column(Selectable):
233234
234235 :param index:
235236 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.
237+ the speed of selects, but can slow down inserts.
238+
239+ :param index_method:
240+ If index is set to True, this specifies what type of index is created.
239241
240242 :param required:
241243 This isn't used by the database - it's to indicate to other tools that
@@ -252,7 +254,8 @@ def __init__(
252254 primary : bool = False ,
253255 key : bool = False ,
254256 unique : bool = False ,
255- index : t .Union [IndexMethod , bool ] = False ,
257+ index : bool = False ,
258+ index_method : IndexMethod = IndexMethod .btree ,
256259 required : bool = False ,
257260 ** kwargs ,
258261 ) -> None :
@@ -266,6 +269,7 @@ def __init__(
266269 "key" : key ,
267270 "unique" : unique ,
268271 "index" : index ,
272+ "index_method" : index_method ,
269273 }
270274 )
271275
@@ -281,6 +285,7 @@ def __init__(
281285 key = key ,
282286 unique = unique ,
283287 index = index ,
288+ index_method = index_method ,
284289 params = kwargs ,
285290 required = required ,
286291 )
0 commit comments