Actions27
- Database Actions
- Storage Actions
Database → Create Index
AI-generatedSummary
Creates a database index on one or more table columns using the Supabase exec_sql RPC function.
Inputs
- tableName (required) — Name of the database table on which to create the index.
- indexDefinition (required) — Configuration object containing 'name' (index name), 'columns' (array of column names), optional 'unique' (boolean), and optional 'method' (indexing method like btree or gin).
Output shape
a single record
Returns an object containing operation ('createIndex'), tableName, indexName, generated sql string, and success status. Requires the exec_sql RPC stored procedure to be enabled in Supabase.
Examples
Example 1: Create an index on a foreign key column
Set tableName to 'orders' and indexDefinition to { "name": "idx_orders_user_id", "columns": ["user_id"] }
Example 2: Create a unique composite index
Set tableName to 'memberships' and indexDefinition to { "name": "idx_unique_user_org", "columns": ["user_id", "org_id"], "unique": true }