Class CreateIndexBuilder<C>

Type Parameters

  • C = never

Hierarchy

  • CreateIndexBuilder

Implements

Constructors

Methods

  • Adds a column to the index.

    Also see columns for adding multiple columns at once or expression for specifying an arbitrary expression.

    Examples

    await db.schema
    .createIndex('person_first_name_and_age_index')
    .on('person')
    .column('first_name')
    .column('age desc')
    .execute()

    The generated SQL (PostgreSQL):

    create index "person_first_name_and_age_index" on "person" ("first_name", "age" desc)
    

    Type Parameters

    • CL extends string

    Parameters

    • column: OrderedColumnName<CL>

    Returns CreateIndexBuilder<C | ExtractColumnNameFromOrderedColumnName<CL>>

  • Specifies a list of columns for the index.

    Also see column for adding a single column or expression for specifying an arbitrary expression.

    Examples

    await db.schema
    .createIndex('person_first_name_and_age_index')
    .on('person')
    .columns(['first_name', 'age desc'])
    .execute()

    The generated SQL (PostgreSQL):

    create index "person_first_name_and_age_index" on "person" ("first_name", "age" desc)
    

    Type Parameters

    • CL extends string

    Parameters

    • columns: OrderedColumnName<CL>[]

    Returns CreateIndexBuilder<C | ExtractColumnNameFromOrderedColumnName<CL>>

  • Specifies an arbitrary expression for the index.

    Examples

    importsql } from 'kysely'

    await db.schema
    .createIndex('person_first_name_index')
    .on('person')
    .expression(sql`first_name COLLATE "fi_FI"`)
    .execute()

    The generated SQL (PostgreSQL):

    create index "person_first_name_index" on "person" (first_name COLLATE "fi_FI")
    

    Parameters

    Returns CreateIndexBuilder<C>

  • Adds nulls not distinct specifier to index. This only works on some dialects like PostgreSQL.

    Examples

    db.schema.createIndex('person_first_name_index')
    .on('person')
    .column('first_name')
    .nullsNotDistinct()
    .execute()

    The generated SQL (PostgreSQL):

    create index "person_first_name_index"
    on "test" ("first_name")
    nulls not distinct;

    Returns CreateIndexBuilder<C>

Generated using TypeDoc