sequelize/sequelize · error · Error

showIndexesQuery has not been implemented in ${this.dialect.

Error message

showIndexesQuery has not been implemented in ${this.dialect.name}.

What it means

Thrown by the base showIndexesQuery, an abstract stub each dialect must override. It backs queryInterface.showIndex / getIndexes and the sync-time index reconciliation. Reaching it means the active dialect's query generator never implemented index introspection.

Source

Thrown at packages/core/src/abstract-dialect/query-generator-typescript.ts:444

      return `SET CONSTRAINTS ${constraintFragment} ${type.toString()}`;
    }

    if (constraints?.length) {
      constraintFragment = constraints
        .map(constraint => this.quoteIdentifier(constraint))
        .join(', ');
    }

    return `SET CONSTRAINTS ${constraintFragment} ${type.toString()}`;
  }

  showConstraintsQuery(_tableName: TableOrModel, _options?: ShowConstraintsQueryOptions): string {
    throw new Error(`showConstraintsQuery has not been implemented in ${this.dialect.name}.`);
  }

  showIndexesQuery(_tableName: TableOrModel): string {
    throw new Error(`showIndexesQuery has not been implemented in ${this.dialect.name}.`);
  }

  removeIndexQuery(
    _tableName: TableOrModel,
    _indexNameOrAttributes: string | string[],
    _options?: RemoveIndexQueryOptions,
  ): string {
    throw new Error(`removeIndexQuery has not been implemented in ${this.dialect.name}.`);
  }

  /**
   * Generates an SQL query that returns all foreign keys of a table or the foreign key constraint of a given column.
   *
   * @deprecated Use {@link showConstraintsQuery} instead.
   * @param _tableName The table or associated model.
   * @param _columnName The name of the column. Not supported by SQLite.
   * @returns The generated SQL query.
   */

View on GitHub (pinned to 7e1deec499)

Solutions

  1. Upgrade the dialect package to one that implements showIndexesQuery.
  2. Read indexes from the catalog directly via sequelize.query.
  3. If authoring the dialect, add showIndexesQuery (see packages/postgres/src/query-generator-typescript.internal.ts:206).

Example fix

// before
const indexes = await queryInterface.showIndex('users');

// after (no showIndexesQuery)
const [indexes] = await sequelize.query(
  `SELECT indexname AS name, indexdef AS definition
   FROM pg_indexes WHERE tablename = 'users'`,
  { type: QueryTypes.SELECT }
);
Defensive patterns

Strategy: fallback

Validate before calling

if (
  sequelize.dialect.queryGenerator.showIndexesQuery ===
  AbstractQueryGenerator.prototype.showIndexesQuery
) {
  throw new Error(`${sequelize.dialect.name} has no showIndexesQuery`);
}

Try / catch

try {
  return await queryInterface.showIndex(table);
} catch (e) {
  if (/showIndexesQuery has not been implemented/.test((e as Error).message)) {
    return sequelize.query(indexesSqlFor(sequelize.dialect.name, table), {
      type: QueryTypes.SELECT,
    });
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling queryInterface.showIndex(table) (or model.sync performing index verification) on a dialect whose generator has no showIndexesQuery override.

Common situations: A community/experimental dialect that ships index creation but not index introspection. Syncing models that declare indexes against such a dialect.

Related errors


AI-assisted analysis of sequelize/sequelize@7e1deec499 (2026-08-03). Data as JSON: /data/errors/da6891ed69bc0e0a.json. Report an issue: GitHub.