Create Index
We want an implementation of
CREATE INDEX ...
and the following helper:
from uuid import UUID, uuid4
from querybuilder.schemas.helper import table, make_column, ColumnSpec
@table
class Person:
id : UUID # TODO change for UUID here
name : str
birth_year: int
Person.create_index(Person.c["id"])
An index can have qualifiers and a name.
Person.create_index(Person.c["id"], unique=True, name="my_index")
It can also admits more complex expression
Person.create_index(Person.c.name.tuple_with(Person.c["birth_year"]), unique=True, name="my_index")
Person.create_index(Person.c[["name", "birth_year"]], unique=True, name="my_index")
Person.create_index(Person.birth_year., unique=True, name="my_index")
PostgreSQL variant admits a index type, WHERE clause for partial coverage and so on. Most of it can be implemented later.