Deprecated. @index exists for backward compatibility with schemas predating @order. New code must use @order(index: "…​") instead. The framework still recognises @index and routes it to the same generator path, but the directive surface, error messages, and how-to pages all assume @order.

Connects an enum value to a database index by name. Functionally identical to @order(index: "…​") with no additional capabilities; the rename happened when @order generalised the surface to include fields: and primaryKey:.

SDL signature

directive @index(name: String) on ENUM_VALUE

Parameters

Name Type Default Description

name

String

none

Name of the database index on the enum’s parent table (resolved via the @orderBy argument that references this enum). Identical semantics to @order’s `index.

Canonical example

# Legacy
enum FilmOrderByField {
    LANGUAGE @index(name: "IDX_FK_LANGUAGE_ID")
    TITLE    @index(name: "IDX_TITLE")
}

# Equivalent, modern
enum FilmOrderByField {
    LANGUAGE @order(index: "IDX_FK_LANGUAGE_ID")
    TITLE    @order(index: "IDX_TITLE")
}

The two forms generate identical code. The migration is a mechanical rename plus a parameter shape change (name: becomes index:).

Constraints

  • Applies only to enum values, like @order.

  • name must resolve to an existing database index when jOOQ index generation is enabled. The same "no matching index" error fires as for @order(index:).

  • @index and @order cannot both decorate the same enum value.

  • Cannot express the field-based or primary-key sorting modes available on @order. Schemas that need those modes must migrate.

Migration

Replace each @index(name: "X") with @order(index: "X"). No runtime behaviour changes; only the directive name and parameter key.

See also

  • @order is the supported replacement.

  • @orderBy is the entry point for both forms.