Home / Function/ createIndexes() — supabase Function Reference

createIndexes() — supabase Function Reference

Architecture documentation for the createIndexes() function in index-advisor.utils.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  b3d1fd6e_4a7f_7c8b_aee3_ae1a137ca67e["createIndexes()"]
  391df4cc_757e_7be6_9737_66a5ae1ad301["IndexSuggestionIcon()"]
  391df4cc_757e_7be6_9737_66a5ae1ad301 -->|calls| b3d1fd6e_4a7f_7c8b_aee3_ae1a137ca67e
  d55bb5d2_0fea_f272_6d89_ad97d7b149c7["QueryIndexes()"]
  d55bb5d2_0fea_f272_6d89_ad97d7b149c7 -->|calls| b3d1fd6e_4a7f_7c8b_aee3_ae1a137ca67e
  style b3d1fd6e_4a7f_7c8b_aee3_ae1a137ca67e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/studio/components/interfaces/QueryPerformance/IndexAdvisor/index-advisor.utils.ts lines 57–91

export async function createIndexes({
  projectRef,
  connectionString,
  indexStatements,
  onSuccess,
  onError,
}: CreateIndexParams): Promise<void> {
  if (!projectRef) {
    const error = new Error('Project ref is required')
    if (onError) onError(error)
    return Promise.reject(error)
  }

  if (indexStatements.length === 0) {
    const error = new Error('No index statements provided')
    if (onError) onError(error)
    return Promise.reject(error)
  }

  try {
    await executeSql({
      projectRef,
      connectionString,
      sql: indexStatements.join(';\n') + ';',
    })

    toast.success('Successfully created index')
    if (onSuccess) onSuccess()
    return Promise.resolve()
  } catch (error: any) {
    toast.error(`Failed to create index: ${error.message}`)
    if (onError) onError(error)
    return Promise.reject(error)
  }
}

Subdomains

Frequently Asked Questions

What does createIndexes() do?
createIndexes() is a function in the supabase codebase.
What calls createIndexes()?
createIndexes() is called by 2 function(s): IndexSuggestionIcon, QueryIndexes.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free