kysely
    Preparing search index...

    Class AlterTableAddIndexBuilder

    Implements

    Index

    Constructors

    Methods

    • Simply calls the provided function passing this as the only argument. $call returns what the provided function returns.

      Type Parameters

      • T

      Parameters

      • func: (qb: this) => T

      Returns T

    • Adds a column to the index.

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

      import { sql } from 'kysely'

      await db.schema
      .alterTable('person')
      .addIndex('person_first_name_and_age_index')
      .column('first_name')
      .column(sql`(left(lower(last_name), 1))`)
      .column('age desc')
      .execute()

      The generated SQL (MySQL):

      alter table `person`
      add index `person_first_name_and_age_index` (
      `first_name`,
      (left(lower(last_name), 1)),
      `age` desc
      )

      Type Parameters

      • CL extends string

      Parameters

      Returns AlterTableAddIndexBuilder

    • Adds a column to the index.

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

      import { sql } from 'kysely'

      await db.schema
      .alterTable('person')
      .addIndex('person_first_name_and_age_index')
      .column('first_name')
      .column(sql`(left(lower(last_name), 1))`)
      .column('age desc')
      .execute()

      The generated SQL (MySQL):

      alter table `person`
      add index `person_first_name_and_age_index` (
      `first_name`,
      (left(lower(last_name), 1)),
      `age` desc
      )

      Parameters

      Returns AlterTableAddIndexBuilder